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.

GGC and Enums

Thread ID:

Created:

Updated:

Platform:

Replies:

79305 Jan 29,2009 05:24 PM Feb 7,2009 03:42 AM Windows Forms 5
loading
Tags: Grouping
Sameer Khan
Asked On January 29, 2009 05:24 PM

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?




Rajadurai C [Syncfusion]
Replied On January 30, 2009 09:17 AM

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


Sameer Khan
Replied On February 2, 2009 10:16 AM

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




Rajadurai C [Syncfusion]
Replied On February 3, 2009 06:35 AM

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


Sameer Khan
Replied On February 5, 2009 09:19 AM

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




Rajadurai C [Syncfusion]
Replied On February 7, 2009 03:42 AM

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


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.

;