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.
Syncfusion Feedback

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

 

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

Article ID: Published Date: Last Revised Date: Platform: Control:
487 04/30/2011 07/10/2014 Windows Forms GridDataBoundGrid(Classic)
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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