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

ComboBox Cell Type

How do I prevent the user from editing a combobox cell? I've set the ExclusiveChoiceList property to true, but I can still clear the cell contents with the space key. Also, is there a way to use the keyboard in the ComboBox cell type to select from the drop-down list? I suppose whay I'm really looking for is a dropdown cell type... perhaps I can get that functionality from a DropDownGrid cell type? Where is the list of supported cell types? Is it only on page 23 of the Grid User's Guide?

4 Replies

CB Clay Burch Syncfusion Team July 18, 2002 09:46 AM UTC

If you set the ExclusiveChoiceList property, then the spacebar should not delete anything. In the CellControlsGrid sample that ships with Essential Grid, the combobox in column 3 is set to be a dropdown only and the spacebar does not clear the cell. Here is the code it uses:
gridControl1[rowIndex, colIndex + 2].CellType = "ComboBox";
gridControl1[rowIndex, colIndex + 2].ChoiceList = items;
gridControl1[rowIndex, colIndex + 2].Text = "Three";
gridControl1[rowIndex, colIndex + 2].ExclusiveChoiceList = true;
You can drop the list, by pressing Alt+downarrow, and then the arrow keys can be used to move the selection, followed by Enter to actually select it and close the dropdown. You can place a button in a static cell if you want to do this, and then catch the click on the button. Attached is a file that does this for a TextBox celltype, but the same technique should work for a Static celltype. There is additional information in the user's guide section 3.4 where is goes through the celltypes and shows code snippets of how you might use them. You can also see usage in the the CellControlsGrid sample mentioned above. Also, read the Samples Readme file on the Start menu. There are several samples that create celltypes like a LinkLabel, ImageCell, TreePM cell, etc.


RM Roy Muller July 18, 2002 10:27 AM UTC

Thanks for the info, Clay. I had similar syntax, but found that I could sometimes clear the cell with the spacebar. I made a small example demonstrating my problem (attached). Run the GridTest exe, select cell 2B with the mouse, select any of the choices with the mouse, then hit the spacebar. You will notice that the cell is cleared :-( Note that if you do the same in cell 3B the same thing happens; it does not seem to be related to the CoveredCells property. Is there a work-around?


CB Clay Burch Syncfusion Team July 18, 2002 01:45 PM UTC

Roy, This is of course a bug. Thanks for reporting it. We'll get it fixed. The reason I did not see it is that I tabbed into the cell, and just hit the spacebar. And the problem appears after the cell is activated for editing by selecting a value. One way to avoid this problem until we get it fixed, is to not leave the cell in the edit mode after a change is made. Normally the cell would remain in the edit mode until you leave the cell somehow. Here is a CurrentCellChanged event handler that seemed to work ok for your sample.
private void gridControl1_CurrentCellChanged(object sender, System.EventArgs e)
{
	if(gridControl1.CurrentCell.Model == gridControl1.CellModels["ComboBox"])
	{
		gridControl1.CurrentCell.EndEdit();
	}
}


AD Administrator Syncfusion Team October 4, 2002 10:28 AM UTC

> Roy, > > This is of course a bug. Thanks for reporting it. We'll get it fixed. > > The reason I did not see it is that I tabbed into the cell, and just hit the spacebar. And the problem appears after the cell is activated for editing by selecting a value. > > One way to avoid this problem until we get it fixed, is to not leave the cell in the edit mode after a change is made. Normally the cell would remain in the edit mode until you leave the cell somehow. Here is a CurrentCellChanged event handler that seemed to work ok for your sample. > >
> private void gridControl1_CurrentCellChanged(object sender, System.EventArgs e)
> {
> 	if(gridControl1.CurrentCell.Model == gridControl1.CellModels["ComboBox"])
> 	{
> 		gridControl1.CurrentCell.EndEdit();
> 	}
> }
> 

Loader.
Live Chat Icon For mobile
Up arrow icon