GGC and Enums

Hello,

I have a GGC bound to a model; one of the attributes is of type enum.

This translates very well to a combobox in the grid.

Now I need to make this something like an exclusive list; is this possible?




5 Replies

RC Rajadurai C Syncfusion Team January 30, 2009 02:17 PM UTC

Hi Sameer,

Thanks for your interest in Syncfusion products.

You can set the DropDownStyle property of combobox to exclusive through hanling QueryCellStyleInfo event.

void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.Style.CellType == "ComboBox")
{
e.Style.DropDownStyle = GridDropDownStyle.Exclusive;
}
}



Regards,
Rajadurai



SK Sameer Khan February 2, 2009 03:16 PM UTC

Hello,

I was already doing that; It doesn't allow the user to type in anything other than the enum set. Which is great.

The problem is; the user;s can still mark it and hit delete, and when this data is being written to the model; it immedialtely throws a validation exception. Because I dont have an enum value = string.empty.

I want to disable this behavior; Making the cell readonly or disabled does not help either; because now the users cannot even select or change the values.

Appreciate your help.

-S


>Hi Sameer,

Thanks for your interest in Syncfusion products.

You can set the DropDownStyle property of combobox to exclusive through hanling QueryCellStyleInfo event.

void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.Style.CellType == "ComboBox")
{
e.Style.DropDownStyle = GridDropDownStyle.Exclusive;
}
}



Regards,
Rajadurai





RC Rajadurai C Syncfusion Team February 3, 2009 11:35 AM UTC

Hi Sameer,

You can prevent the user from deleting the value in combobox cell through the following code handled in TableControlCurrentCellKeyDown event.

void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
if (cc.Renderer is GridComboBoxCellRenderer)
{
GridComboBoxCellRenderer rend = cc.Renderer as GridComboBoxCellRenderer;
if (rend != null)
{
if (e.Inner.KeyCode == Keys.Delete || (Control.ModifierKeys & Keys.Control) != 0 && e.Inner.KeyCode == Keys.X)
{
e.Inner.Handled = true;
}
}
}
}


Regards,
Rajadurai



SK Sameer Khan February 5, 2009 02:19 PM UTC

Hello,
The code is in the right direction; however the user can still mark the cell and hit backspace to clear off the cell.

Even when I handle the backspace key ( I see the e.Handled = true code is being executed ) the cell clears off; Is there something I am missing.


>Hi Sameer,

You can prevent the user from deleting the value in combobox cell through the following code handled in TableControlCurrentCellKeyDown event.

void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
if (cc.Renderer is GridComboBoxCellRenderer)
{
GridComboBoxCellRenderer rend = cc.Renderer as GridComboBoxCellRenderer;
if (rend != null)
{
if (e.Inner.KeyCode == Keys.Delete || (Control.ModifierKeys & Keys.Control) != 0 && e.Inner.KeyCode == Keys.X)
{
e.Inner.Handled = true;
}
}
}
}


Regards,
Rajadurai





RC Rajadurai C Syncfusion Team February 7, 2009 08:42 AM UTC

Hi Sameer,

I tried with the following code,

void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
if (cc.Renderer is GridComboBoxCellRenderer)
{
GridComboBoxCellRenderer rend = cc.Renderer as GridComboBoxCellRenderer;
if (rend != null)
{
if (e.Inner.KeyCode == Keys.Delete || ((Control.ModifierKeys & Keys.Control) != 0 && e.Inner.KeyCode == Keys.X)||e.Inner .KeyCode == Keys .Back)
{
e.Inner.Handled = true;
}
}
}

}


On selecting cells and pressing Backspace key, the cell content is not getting cleared. If you still see the issue, please provide a minimal sample in which issue can be reproduced.

Regards,
Rajadurai


Loader.
Up arrow icon