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

Evaluating Essential Suite

I am in the process of evaluating the Essential Grid, and would appreciate some additional information. In my own very primitive "home rolled" grid I override OnPaint of a datagridcolumnstyle and have a user supplied format. The Commit is also overridden to parse the formatted text before committing it to the datasource. An example: Raw data 1/3/2003 - formatted as Mar 03 Raw data 2/3/2003 - formatted as M/A 03 Raw data 1/9/2003 - formatted as Sep 03 Raw data 2/9/2003 - formatted as S/O 03 Raw data 0 - formatted as "C" Raw data 1 - formatted as "S" etc etc. My questions is if it is possible to do something similar with the Essential Grid. Another question - my computer is set up for CultureInfo GB - i.e. UK date, dd/mm/yyyy. While the data in the grid correctly shows the UK date format, entering a partial date with UK format throws an invalid date format error, ie. 29/3 (the standard grid will complete this to 29th March 2003 even if the year has not been supplied), but the Essential Grid balks at the date. Many thanks in advance Jeremy Holt

2 Replies

AD Administrator Syncfusion Team April 14, 2003 02:44 PM UTC

In regard to your second question, if you do not explicilty set teh GridStyleInfo.Format for the cell, then you can type something like 4/4 and teh grid will populate the missing datetime information. But if you provide the format, then the grid uses the ParseExact to enforce the format. One way around this is to handle CurrentCellValidating and take the incoming string and populate it properly so there are no missing pieces.
//in form load
this.gridControl1.ColWidths[2] = 120;
GridStyleInfo style = this.gridControl1[2,2];
style.BackColor = Color.LightBlue;
style.CellValue = DateTime.Now;
style.CellValueType = typeof(DateTime);
style.Format = "g";

private void gridControl1_CurrentCellValidating(object sender, CancelEventArgs e)
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	GridStyleInfo style = this.gridControl1[cc.RowIndex, cc.ColIndex];
	if(style.Format.Length > 0 && style.CellValueType == typeof(DateTime))
		string val = cc.Renderer.ControlText;
			DateTime dt = DateTime.Parse(val); //takes almost anything
			val = dt.ToString(style.Format); //force it to the desired format
			cc.Renderer.Control.Text = val; //set it into the control
		{} //empty catch
With respect to your first question, our upcoming 1.6 release has two new events designed to handle exactly this task, QueryCellFormattedText and SaveCellFormattedText. 1.6 goes into beta this week.

UN Unknown Syncfusion Team April 14, 2003 06:59 PM UTC

Clay Thanks very much for the info Regards Jeremy

Live Chat Icon For mobile
Up arrow icon