Modified the code again ...
CODE
public void Flex_ColumnValidation(int column,Type datatype )
{
if (cfg.Cols[column].DataType == datatype)
{
NumericUpDown editor = new NumericUpDown();
editor.Increment = 1;
editor.Maximum = 1000;
editor.Minimum = 1;
editor.ReadOnly = true;
editor.BorderStyle = BorderStyle.None;
C1.Win.C1Input.C1DateEdit dateedit = new Win.C1Input.C1DateEdit();
dateedit.VisualStyle = C1.Win.C1Input.VisualStyle.Office2007Blue;
dateedit.FormatType = C1.Win.C1Input.FormatTypeEnum.ShortDate;
C1.Win.C1FlexGrid.CellRange Crange;
C1.Win.C1FlexGrid.CellStyle cs = cfg.Styles.Add("DateTime");
cs.DataType = datatype;
cs.Format = "dd-MMM-yyyy";
cs = cfg.Styles.Add("Decimal");
cs.DataType = datatype;
cs.Format = "0,000.00";
cs.EditMask = "0000.00";
cs = cfg.Styles.Add("String");
cs.DataType = datatype;
cs.Format = "LLLLL";
cs.EditMask = "LLLLLLLLLL";
cs.Font = new Font(Font,FontStyle.Italic);
cs = cfg.Styles.Add("Integer");
cs.DataType = datatype;
cs.EditMask = "0000000000";
cs.Editor = editor;
cs = cfg.Styles.Add("Currency");
cs.DataType = datatype;
cs.Format = "c";
cs.EditMask = "0000.00";
cs.Font = new Font(Font, FontStyle.Bold);
if (datatype ==typeof(DateTime))
{
Crange = cfg.GetCellRange(1, column , 1, column);
Crange.Style = cfg.Styles["DateTime"];
}
else if (datatype == typeof(decimal))
{
Crange = cfg.GetCellRange(1, column);
Crange.Style = cfg.Styles["Currency"];
}
else if (datatype == typeof(string))
{
Crange = cfg.GetCellRange(1,column);
Crange.Style = cfg.Styles["string"];
}
else if (datatype == typeof(Int32))
{
Crange = cfg.GetCellRange(1, column);
Crange.Style = cfg.Styles["Integer"];
}
}
else
MessageBox.Show("Invalid Datatype");
}
want to use this method for validation in some projects.. Want to pass parameters as per the requirement. Any idea how to generalize it?