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

ComboBox behavior only when current cell, /and/ Editable

The behavior I'd like is *almost* like setting StyleInfo.ShowButtons = GridShowButtons.ShowCurrentCellEditing, except that if a cell is not editable, I want it to only display the current value in a static field cell.

Right now I'm making a cell editable by setting it's StyleInfo.ReadOnly = false, and I always set my ComboBoxes' StyleInfo.ShowButtons property as above. It's almost what I want, but the button still displays even if the user is not able to edit the cell. How can I get that behavior? Is there another 'editable' setting besides ReadOnly?

6 Replies

AD Administrator Syncfusion Team April 10, 2007 02:31 PM UTC

Try handling the CurrentCellStartEditing event and set e.Cancel = true if you do not want the particular current cell to go into edit mode. Here is code that would not let any combobox cells go into edit mode.

void gridControl1_CurrentCellStartEditing(object sender, CancelEventArgs e)
{
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
if (grid[cc.RowIndex, cc.ColIndex].CellType == "ComboBox")
{
e.Cancel = true;
}
}


KO Ken Overton April 10, 2007 02:54 PM UTC

>Try handling the CurrentCellStartEditing event and
> set e.Cancel = true if you do not want the
> particular current cell to go into edit mode.

That's what I was afraid of; there's no general-purpose way of doing this, then? These kind of special case overrides tend to pile up, and get entangled with each other.


AD Administrator Syncfusion Team April 10, 2007 03:31 PM UTC

If you want this behavior to apply to an entire column, then you can just set style.CellType for that column to be "Static" instead of "ComboBox".


grid.TableDescriptor.Columns["myColumn"].AnyCell.CellType = "Static";


But if you want to conditionally apply this setting on a record by record basis, then you will have to handle some event.


KO Ken Overton April 10, 2007 04:12 PM UTC

I understand; you could also say that if a cell's StyleInfo.ReadOnly = true, it shouldn't ever go into edit mode. Then all I have to do to get the best behavior is to set the right StyleInfo properties.


AD Administrator Syncfusion Team April 10, 2007 04:21 PM UTC

Not actvating a cell on ReadOnly = false would not be consistant with other Windows Forms Controls like Text.

Also, setting StyleInfo.CellType = "Static" is no more involved than setting StyleInfo.ReadOnly = true. They are both style settings.


KO Ken Overton April 10, 2007 04:33 PM UTC

Thanks, hadn't considered what the windows behavior is for other components.

Loader.
Live Chat Icon For mobile
Up arrow icon