User (Old forums)MemberMay 7, 2009 at 10:02 amPost count: 23064
I have a requirement to have a single column that displays a variable list of icons (or small images) that can be clicked. I would need to know which icon was clicked.
What is the best way to do this?
Imported from legacy forums. Posted by Bernard (had 2049 views)User (Old forums)MemberMay 8, 2009 at 10:55 amPost count: 23064
Do you mean there is a list of icons within each cell, or each cell has only one icon? If the later, you can simply use the CurrentCellChanged event on the GridControl, and in the event handler, simply verify which icon is associated to this cell.
If the previous, can you provide more details on how you set up this column and the viewer you are using inside it?
Imported from legacy forums. Posted by André (had 340 views)User (Old forums)MemberMay 9, 2009 at 3:42 pmPost count: 23064
The want a variable list of “command” icons for the various things you can do depending on what is in the row in a single column (other wise there would be to many columns if there was a separate column for each command type.
Imported from legacy forums. Posted by Bernard (had 1773 views)User (Old forums)MemberMay 11, 2009 at 4:22 pmPost count: 23064
First, you will need to build your own editor control which can contain as many icons that it needs, and have each of these icon be click-able. For example, you could have panel (or a user control or whatever else you can think of) containing buttons which have their background image set to one of the icon.
Then you will need to initialize one editor for each cell since it can have varying number of icons/buttons. You can do that in the AddingDataRow event handler, where you can use the e.DataRow.Cells[ EditorColumn ].CellEditorManager property to set a new editor control each time it is triggered.
Finally, you will need to subscribe to the ActivatingControl and DeactivatingControl event on the CellEditorManager for the column, which will be use to handle the click event on the different icons/buttons.
Here is an example of this with a WinComboBox control :
private void Form1_Load(object sender, System.EventArgs e)
gridControl1.Columns[ ComboBoxColumn ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(ComboBoxColumn_ActivatingControl);
gridControl1.Columns[ ComboBoxColumn ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(ComboBoxColumn_DeactivatingControl);
private void ComboBoxColumn_ActivatingControl(object sender, CellEditorEventArgs e)
( ( WinComboBox )e.Control).SelectedIndexChanged += new EventHandler(ComboBoxColumn_SelectedIndexChanged);
private void ComboBoxColumn_DeactivatingControl(object sender, CellEditorEventArgs e)
//need to unsubscribe to the event, so it does not keep piling up in the ActivatingControl
( ( WinComboBox )e.Control).SelectedIndexChanged -= new EventHandler(ComboBoxColumn_SelectedIndexChanged);
private void ComboBoxColumn6_SelectedIndexChanged(object sender, EventArgs e)
string index = “index ” + ( ( WinComboBox )sender).SelectedIndex.ToString();
System.Diagnostics.Debug.WriteLine( index );
Imported from legacy forums. Posted by André (had 2274 views)
- You must be logged in to reply to this topic.