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
close icon

Binding option list to grid cells using context menu

Hi ,
We are planning to use sync fusion gird control for one of our major project using WPF .Our requirement is to be able to display excel sheet
Like control to user where they can enter only predefined vales like ‘yes’, ‘No’,’Good’,’bad’ etc in the 2nd column of the grid control .If they try to enter ‘yep’ instead of ‘yes’ we should not let them enter ‘p’ in yep and cell value should get clear when they move to next cell and also we should let them enter special character Like ‘Ctrl D’ for delete.
Here is the code I am using which is partial working .But not sure how to handle special case character like ‘Ctrl D’ and also like to know how to bind context menu to specific column dynamically at runtime…
I am attaching the screen short of the existing where we trying to re-write using sync fusion gird control using WPF.
Any sample project will be greatly appreciated.


private void grid_CurrentCellEditingComplete(object sender, SyncfusionRoutedEventArgs e)
{
ExcelGridControl grid = sender as ExcelGridControl;

if (grid != null)
{ GridCurrentCell cc = grid.CurrentCell;
GridStyleInfo style = grid.Model[cc.RowIndex,c.ColumnIndex];

//set the background style
style.Background = new SolidColorBrush(Colors.White);

//check if any constraints were specified and if valid values were entered
if (style.ChoiceList != null && style.ChoiceList.Count > 0 && style.CellValue != null)
{
if (!style.ChoiceList.Contains(style.CellValue.ToString()))
{
style.CellValue = string.Empty;
style.Background = new SolidColorBrush(Colors.Yellow);
}
}

object value = cc.Renderer.ControlValue;
}
}

// Binding to cell code
this.dgMain.Model[3, 2].ChoiceList = items;

//create option list
StringCollection items = new StringCollection();
items.Add("Yes");
items.Add("No");




untitled12_dbf8a5ea.zip

1 Reply

DP Dhinesh Pandiyan M Syncfusion Team February 1, 2010 02:31 PM UTC

Hi Sireesha,

Thanks for using Syncfusion products.

This problem has been resolved and updated in the incident #64116.

Please let us know if have any other questions.

With Regards,
Dhinesh Pandiyan

Loader.
Live Chat Icon For mobile
Up arrow icon