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

Changing format in GridListControl

Hi, I am loading a gridlistControl with a datatable. One of the columns is a DateTime. I need to format the column as dd-MMM-YYYY hh:mm:ss, however am having some difficulties. I am following the example from http://64.78.18.34/support/EvaluationCenter/viewsource.aspx?lang=csharp&id=80 When I try and set the CellValuetype, I get the following error: "Specified argument was out of the range of valid values. Parameter name: colIndex" Can someone please help? Also, while I''m here, I am refering to the column as [1] (I''ve tried [0] and [2] as well). Is there anyway I can refer to the column name "Snap Date"? Thanks in advance, Damien Sawyer ----------------- Code Below ----------------- public void LoadSnapshotslist() { try { DataTable dtSnaps = new DataTable(); string sSQL = @"select iSnapshotID [Snapshot ID], dDateTime [Snap Date] from tblOrdersReturnSnapshots order by dDateTime desc"; SqlDataAdapter sDA = new SqlDataAdapter(sSQL,_application.DataBinder.Session.Connection as SqlConnection); sDA.Fill(dtSnaps); this.glSnapshots.DataSource = dtSnaps; this.glSnapshots.Grid.ColStyles[1].CellValueType = typeof(DateTime); this.glSnapshots.Grid.ColStyles[1].Format="dd-MMM-yy hh:mm"; this.glSnapshots.MultiColumn = true; this.glSnapshots.SelectionMode = SelectionMode.MultiExtended; } catch (System.Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show(ex.Message); } }

1 Reply

AD Administrator Syncfusion Team September 22, 2005 12:46 PM UTC

Hi Damien, The format of the cells can be changed in the QueryCellInfo event of the GridListControl. The code snippet is as follows, Declaration of QueryCellinfo: gridListControl1.Grid.QueryCellInfo +=new Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventHandler(Grid_QueryCellInfo); Event: private void Grid_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e) { e.Style.Format="MM/dd/yyyy hh:mm:ss"; } Regards, Leo.

Loader.
Live Chat Icon For mobile
Up arrow icon