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

prevent combobox cell from dropping down

I have a databound grid which contains a GridBoundColumn which I initialize with a CellType of "ComboBox". I then set the DataSource, DisplayMember, and ValueMember in order to display the proper value in the cell. For certain rows, however, I need to set the cells to readonly which I do by setting e.Style.ReadOnly = True in the grid.model.QueryCellInfo routine. Although this prevents the user from selecting a different choice it does not prevent the combobox from displaying the drop down. I tried setting e.Style.CellType = "Static" for these cells in PrepareViewStyleInfo, however this caused the cell to no longer display the DisplayMember. Is there a way to retain the properties of the ComboBox cell while dynamically preventing it from showing the dropdown?

2 Replies

AD Administrator Syncfusion Team December 29, 2004 06:35 PM UTC

You can handle the grid.CurrentCellShowingDropDown event and cancel it if the currentcell is readonly.
private void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	if(this.gridControl1[cc.RowIndex, cc.ColIndex].ReadOnly)
		e.Cancel = true;
}


JL Jeff Lancaster December 29, 2004 07:04 PM UTC

Excellent! Thanks Clay.

Loader.
Up arrow icon