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.
Unfortunately, activation email could not send to your email. Please try again.

Changing format in GridListControl

Thread ID:

Created:

Updated:

Platform:

Replies:

35063 Sep 21,2005 10:21 PM Sep 22,2005 08:46 AM Windows Forms 1
loading
Tags: GridControl
Damien Sawyer
Asked On September 21, 2005 10:21 PM

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

Administrator [Syncfusion]
Replied On September 22, 2005 08:46 AM

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.

CONFIRMATION

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.

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.

;