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.
Unfortunately, activation email could not send to your email. Please try again.

ComboBox behavior only when current cell, /and/ Editable

Thread ID:

Created:

Updated:

Platform:

Replies:

59283 Apr 10,2007 10:12 AM Apr 10,2007 12:33 PM Windows Forms 6
loading
Tags: GridControl
Ken Overton
Asked On April 10, 2007 10:12 AM

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?

Administrator [Syncfusion]
Replied On April 10, 2007 10:31 AM

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;
}
}

Ken Overton
Replied On April 10, 2007 10:54 AM

>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.

Administrator [Syncfusion]
Replied On April 10, 2007 11:31 AM

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.

Ken Overton
Replied On April 10, 2007 12:12 PM

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.

Administrator [Syncfusion]
Replied On April 10, 2007 12:21 PM

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.

Ken Overton
Replied On April 10, 2007 12:33 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;