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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Changing format in GridListControl

Thread ID:





35063 Sep 22,2005 02:21 AM UTC Sep 22,2005 12:46 PM UTC WinForms 1
Tags: GridControl
Damien Sawyer
Asked On September 22, 2005 02:21 AM UTC

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 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); } }

Administrator [Syncfusion]
Replied On 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.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon