)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to insert animated image to a grid cell in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 19, 2015 |
Last Revised Date: December 20, 2019

Inserting an animated image to a grid cell

You can animate the image inside the Grid cell by setting the CellType as Picturebox control and you can customize the timer to refresh the picture displaying time interval for displaying pictures like animated one. The following code example explains how to set cell type and refreshing the grid in a proper interval time.

C#

// Creates picture instance.
pb.Image = Image.FromFile(@"..\\..\\Camera_4.gif");
Timer t = new Timer() { Interval = 50 };
t.Tick += new EventHandler(t_Tick);
t.Start()
void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
    if (e.ColIndex == 1 && e.RowIndex == 1)
    {
        // Sets Cell Type.
        e.Style.CellType = GridCellTypeName.Control;
        // sets image to the cell.
        e.Style.Control = pb;
    }
}
// Refreshes the grid.
void t_Tick(object sender, EventArgs e)
{
 if (gridControl1.CurrentCell != null && !gridControl1.CurrentCell.HasCurrentCellAt(1, 1))
  {
    gridControl1.RefreshRange(GridRangeInfo.Cell(1, 1));    
  }
}

 

VB

' Creates picture instance.
pb.Image = Image.FromFile("..\\..\\Camera_4.gif")
Dim t As New Timer() With {.Interval = 50}
AddHandler t.Tick, AddressOf t_Tick
t.Start() void gridControl1_QueryCellInfo(Object sender, GridQueryCellInfoEventArgs e)
 If e.ColIndex = 1 AndAlso e.RowIndex = 1 Then
  ' Sets Cell Type.
  e.Style.CellType = GridCellTypeName.Control
  ' sets image to the cell.
  e.Style.Control = pb
 End If
' Refreshes the grid.
void t_Tick(Object sender, EventArgs e)
 If gridControl1.CurrentCell IsNot Nothing AndAlso (Not  gridControl1.CurrentCell.HasCurrentCellAt(1, 1)) Then
  gridControl1.RefreshRange(GridRangeInfo.Cell(1, 1))
End If

 

The following screenshot displays the image loaded and refreshed in a cell.

Added animated image to the grid cell

Samples:

C#: AnimatedImage-C#

VB: AnimatedImage-VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon