)
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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I set the format for the drop-down list of the GridFilterBar's DateTime column in the GDBG?

Platform: WinForms |
Control: GridDataBoundGrid(Classic) |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

After wiring the grid, you can explicitly adjust the FilterBar's droplists. The attached sample changes the FilterBar's droplist date-time format.

C#

/Wire the GridFilterBar

GridFilterBar filter = new GridFilterBar();

filter.WireGrid(this.gridDataBoundGrid1);

//change the dateformats for the GridFilterBar dropdown

int col = this.gridDataBoundGrid1.Binder.NameToColIndex("Col1");

if(col > -1)

{

DataTable dt1 = (DataTable) this.gridDataBoundGrid1[1, col].DataSource;

for(int i = 2; i <dt1.Rows.Count; ++i)

dt1.Rows[i][0] = DateTime.Parse((string) dt1.Rows[i][0]).ToShortDateString();

}

}

VB

Wire the GridFilterBar

Dim filter As New GridFilterBar()

filter.WireGrid(Me.gridDataBoundGrid1)

'change the dateformats for the GridFilterBar dropdown

Dim col As Integer = Me.gridDataBoundGrid1.Binder.NameToColIndex("Col1")

If col > - 1 Then

Dim dt1 As DataTable = CType(Me.gridDataBoundGrid1(1, col).DataSource, DataTable)

Dim j As Integer

For j = 2 To dt1.Rows.Count - 1

dt1.Rows(j)(0) = DateTime.Parse(CType(dt1.Rows(j)(0), String)).ToShortDateString()

Next

End If

Here is the link with both CS and VB samples: http://websamples.syncfusion.com/samples/KB/Grid.Windows/GDBGFormatFilter/main.htm

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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

Live Chat Icon For mobile
Live Chat Icon