this.gridGroupingControl1.SaveCellFormattedText += GridGroupingControl1_SaveCellFormattedText;
private void GridGroupingControl1_SaveCellFormattedText(object sender,GridCellTextEventArgs e)
{
bool value;
if (bool.TryParse(e.Text, out value))
e.Style.CellValueType = typeof(bool);
else
e.Style.CellValueType = typeof(string);
} |
Mohanraj,
Outstanding! So, basically the control needs to have the types defined in e.Style.CellValueType.
What I did to simplify my code was to assign the types in QueryCellStyleInfo event and now I don't need to Parse for a boolean when setting the GenericConfiguration.SettingValue property:
private void ggcSettings_QueryCellStyleInfo(object Sender, GridTableCellStyleInfoEventArgs e)
{
Debug.Print("r: " + e.Style.TableCellIdentity.RowIndex + " c: " + e.Style.TableCellIdentity.ColIndex + " val: " + e.Style.CellValue);
//string d = "row: {0} col: {1} - {2}";
//Debug.Print(string.Format(d, e.TableCellIdentity.RowIndex, e.TableCellIdentity.ColIndex, e.Style.CellValue.ToString() + ""));
if (e.TableCellIdentity.RowIndex > 1)
{
if (e.TableCellIdentity.ColIndex == 1)
{
e.Style.Enabled = false;
}
if (e.TableCellIdentity.ColIndex == 2)
{
if (e.Style.CellValue.ToString() != "")
{
if (_lstSettings[e.TableCellIdentity.RowIndex - 2].SettingValue.GetType() == typeof(Boolean))
{
e.Style.CellType = "ComboBox";
e.Style.CellValueType = typeof(Boolean);
e.Style.ChoiceList = _lstBools;
e.Style.DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.AutoComplete;
e.Style.AutoCompleteInEditMode = Syncfusion.Windows.Forms.Grid.GridComboSelectionOptions.AutoComplete;
}
else
{
e.Style.CellValueType = _lstSettings[e.TableCellIdentity.RowIndex - 2].SettingValue.GetType();
}
}
else
{
e.Style.CellValueType = _lstSettings[e.TableCellIdentity.RowIndex - 2].SettingValue.GetType();
}
}
}
}
internal class GenericConfiguration : INotifyPropertyChanged
{
Thanks very much for the help!