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.
Unfortunately, activation email could not send to your email. Please try again.

Using ImageLists in GridDataBoundGrids

Thread ID:

Created:

Updated:

Platform:

Replies:

17811 Aug 17,2004 02:55 PM Aug 19,2004 08:23 AM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 17, 2004 02:55 PM

I have a few questions about using ImageLists in cells of a databound grid: 1. How can manually select what imageIndex to use for a cell at run time. (I.E. i want to select an image to show in a cell based off of a value in another column for that row.) 2. I would like to add an image to items that get displayed in a dropdownlist for a combocell. In this case, the value stored in the grid is an id that is mapped to another table in the database. I am getting the name of that id from the database, but I would like to display an image in the drop down based upon another column in the mapping table. (An example of what I want to do might be, a grid used for customer orders in a store. The customer can select an item he wishes to buy from a drop down. However, some items might be out of stock. I would like to display an icon showing that the item is either in stock, or is out of stock). Thank you.

Administrator [Syncfusion]
Replied On August 17, 2004 03:06 PM

1) You can handle the PrepareViewStyleInfo event. If e.ColIndex points to the column with the bitmap, you can set e.Style.ImageIndex to whatever value you want. If you need to get a value from another column within PrepareViewStyleInfo, then inside the If statement that you use to check the value of e.ColIndex, you can use an indexer on the grid, grid[e.RowIndex, someColIndex].CellValue, to get the value from another column. 2)Instead of a ComboBox celltype, you can use a GridListControl celltype and that will display an icon in a column. You can see a sample in this sample, Grid\Samples\CellTypes\ComboboxCells, that ships with the product. Look at the bottom of the grid in the sample.

Administrator [Syncfusion]
Replied On August 19, 2004 07:27 AM

Thanks, I was able to get #1 to work. However, I still don''t understand how the icon gets set in the dropdown. I see you are using an ArrayList of items, and each item has a property called ImageIndex, but I never see anyone getting that property. Or should I just assume that the control is doing that automagically? Does that mean I should creeate a datatable as the datasource with the columns: Display, Value, and ImageIndex? Thanks

Administrator [Syncfusion]
Replied On August 19, 2004 08:23 AM

You can do it that way adding a field to your dropdown''s data source named ImageIndex. If you do not want to do this, you can subscribe to the dropdown''s embedded grid''s PrepareViewStyleInfo event, and dynamically set e.Style.ImageIndex and e.Style.ImageList at that point based on some criteria or cache of values. Here is a little sample that uses this second technique. It also has commented out the first technique if you want to try that as well. (But don''t try using both as that might confuse things.) ComboRelations_6371.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;