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

Images and Choice list cell types

Can a ComboBox cell type be made to display an image with each choice item? In the CellControlsGrid example, how does the GridListControl know that an image index is kept in the USState.ImageIndex property? i.e. Is the "ImageIndex" property name hard coded in the essential suite code? How do I change the MultiColumn value for a GridListControl cell type? It doesn't seem to be in the GridStyleInfo class for definition via the designer. Is their a way of controlling which columns are displayed by a GridListControl cell without modification of the data source contents?

2 Replies

AD Administrator Syncfusion Team March 10, 2003 09:20 AM UTC

There is some code sample in the gridpad sample project. See Grid\Samples\Quick Start\GridPad. The class is SampleGrid.cs. Look for this code: model[rowIndex, 1].Text = "GridListControl (List)"; model[rowIndex, 3].CellType = "GridListControl"; model[rowIndex, 3].ChoiceList = items; model[rowIndex, 3].DataSource = USStates ; model[rowIndex, 3].ExclusiveChoiceList = true; // tell combobox to behave like CBS_DROPDOWNSTYLE The image index is specified with the ImageIndex property of the following class: [Serializable] public class USState { private string myShortName ; private string myLongName ; private int _imageIndex; public USState(string strLongName, string strShortName, int _imageIndex) { this.myShortName = strShortName; this.myLongName = strLongName; this._imageIndex = _imageIndex; } public string ShortName { get { return myShortName; } } public string LongName { get { return myLongName ; } } public int ImageIndex { get { return _imageIndex; } set { _imageIndex = value; } } public override string ToString() { return this.ShortName + " - " + this.LongName; } } Stefan


AD Administrator Syncfusion Team March 10, 2003 09:58 AM UTC

> Can a ComboBox cell type be made to display an image with each choice item? There are no property setting for this. You woul dhave to derive your own combobox celltype, override the renderer's OnDraw and draw the image yourself. It is certainly doable. But you might want to consider using a GridListControl cell as this already has this capbility. > > In the CellControlsGrid example, how does the GridListControl know that an image index is kept in the USState.ImageIndex property? i.e. Is the "ImageIndex" property name hard coded in the essential suite code? For the GridListControl, the 'ImageIndex' name is currently hard codeed around line 560 of GridListControl.cs. The GridListControl does have an embedded GridControl that you can use to completely control how/what/where preopties are displayed. You do so by handling the QueryCellInfo event for the embedded grid. Attached is a sample that does this for a GridListControl used in a ComboBoxExt and as a cell in a GridControl. It uses a different property other than "ImageIndex" to specify the image. Notice that for the GridListControl in a cell, the events are hooked and unhooked on teh CurrentCellShowingDropDown and CurrentCellCloseDropdown. This is because every cell might have a different list. > How do I change the MultiColumn value for a GridListControl cell type? It doesn't seem to be in the GridStyleInfo class for definition via the designer. You cannot do it through the designer becuase that is a property of the GridListControl itself, and is not a property in the GridStyleInfo class. And since the GridListControl is shared among any cells using it, you would want to set such a property on a cell by cell basis. One place you could do this is in CurrentCellShowingDropdown. Here is some code.
private void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	if(cc.RowIndex == 2 && cc.ColIndex == 2) 
	{
		GridDropDownGridListControlCellRenderer cr = cc.Renderer as GridDropDownGridListControlCellRenderer;
		if(cr != null)
		{
			cr.ListControlPart.MultiColumn = false;
		}
	}
}
> Is their a way of controlling which columns are displayed by a GridListControl cell without modification of the data source contents? You can do this in the embedded grid QueryCellInfo. See the sample.

Loader.
Up arrow icon