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. Image for the cookie policy date
close icon

Image in cell

I have a problem with ImageList in a Column (GridDataVisibleColumn).

I've made a UserControl containing a GridDataControl (from Essential Studio v.8.4.0.10). I would like to add an ImageList to one of the columns (GridDataVisibleColumn) that has an Integer value. This value is equal to the index of the Image in the ImageList. If the Integer value changes, the Image should also change automatic. So if the Integer value changes to 3, the it shows the Image on index 3 from the ImageList.

How is this done? - please send an example in C-Sharp.

Here is the mainpart of my code (in UserControl_Loaded):

ObservableCollection myImageList = new ObservableCollection();
string[] mySymbols = new string[] { "MessageTypeNone.ico", "MessageTypeInformation.ico", "MessageTypeWarning.ico", "MessageTypeCritical.ico", "MessageTypeCritical.ico", "MessageTypeRegistration.ico", "MessageTypeCrediting.ico" };foreach (string Symbol in mySymbols)
{
Image myImage = new Image();
myImage.Source = new BitmapImage(new Uri("Images/" + Symbol, UriKind.Relative));
myImageList.Add(myImage);
}

Syncfusion.Windows.Controls.Grid.GridDataVisibleColumn myColumn = dgrdLog.VisibleColumns["Level"];
Syncfusion.Windows.Controls.Grid.GridDataControlLength myTypeWidth = new Syncfusion.Windows.Controls.Grid.GridDataControlLength(48);
myColumn.Width = myTypeWidth;
Syncfusion.Windows.Controls.Grid.GridDataColumnStyle myTypeStyle = new Syncfusion.Windows.Controls.Grid.GridDataColumnStyle();
myTypeStyle.CellType = "Image";
myTypeStyle.ImageList = myImageList;
myColumn.ColumnStyle = myTypeStyle;

Thanks in advance...



2 Replies

BF Benny Filtenborg February 8, 2011 02:01 PM UTC

I forgot to tell that I'm using a DataTable as SourceItem. The valuechanges will only be made in the DataTable, not in the GridDataControl.

Another question: How do I make the Grid refresh when changes are made in the DataTable? - is the an automatic way- or a manually way to do this?

Thanks in advance...



MA Manikandan Syncfusion Team February 23, 2011 07:44 AM UTC

Hi Benny,

Thanks for using Syncfusion Products.

We have created a sample for your requirement. To list the Image in a column based on the index value in cell. Please find the sample in the following location.
By default when we change the value in the DataTable, it will get update into the GridDataControl it is one of the general behavior.By setting the NotifyPropertyChange property as true Grid will automatically listen to the changes in the source and get update itself. We don’t to force the Grid to refresh.

Sample Location:
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=ImageColumnSample-1294091235.zip

Please let us know if you need more information.

Regards,
Manikandan J R.



Loader.
Live Chat Icon For mobile
Up arrow icon