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

Dropdown calendar events

I need to display the date as yyyyMMdd. I want to use a drop down calendar. Can I trap on the calendar events when the user clicks on the down arrow to correctly load the calendar and went the user selects a date.

9 Replies

AD Administrator Syncfusion Team May 21, 2003 07:56 PM UTC

Here are some trys at doing this. First, set the style.Format for the cell to your "yyyyMMdd" format. (In a GridDataBoundGrid, this would be in the GridBoundColumn or the Binder.InternalColumns). Then handle the CurrentCellShowingDropDown and CurrentCellCloseDropDown events to swap things out.
private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.Renderer is GridDropDownMonthCalendarCellRenderer)
	{
		GridDropDownMonthCalendarCellRenderer cr = cc.Renderer as GridDropDownMonthCalendarCellRenderer;
		DateTime dt = (DateTime) cc.Renderer.ControlValue;
		cc.Renderer.ControlText = dt.ToString("g");
	}
}

private void gridDataBoundGrid1_CurrentCellCloseDropDown(object sender, PopupClosedEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.Renderer is GridDropDownMonthCalendarCellRenderer)
	{
		GridDropDownMonthCalendarCellRenderer cr = cc.Renderer as GridDropDownMonthCalendarCellRenderer;
		DateTime dt = (DateTime) cc.Renderer.ControlValue;
		cc.Renderer.ControlText = dt.ToString("yyyyMMdd");
	}
}


MS Martin Squicciarini May 22, 2003 11:27 AM UTC

Clay, I'm using a virtual grid and I don't seem to have a reference to the CurrentCellShowingDropDown event


AD Administrator Syncfusion Team May 22, 2003 11:42 AM UTC

What version are you running? It should be in the latest 1.5.2.0 public release available from your support home page. I can see it both in intellisense and in the DevStu fucntionality for adding event handlers.


AD Administrator Syncfusion Team May 22, 2003 12:23 PM UTC

Attached is a sample that runs in the 1.6 beta. It will not work in the 1.5.2.0 latest public release though. If you own the product and submit a Direct Trac support incident, you can get a download link for the latet 1.6 beta code.


MS Martin Squicciarini May 22, 2003 12:29 PM UTC

Just checked and I am using version 1.5.1.1 of the grid. Will it work there. Either way I will download the latest. BTW here is the code that I'm using. Maybe you can see something Public Sub New(ByVal Columns As cColumnCollection, ByVal dtGrid As DataTable, ByVal Grid As Syncfusion.Windows.Forms.Grid.GridControl, ByVal BusinessLogic As cBusinessLogic, ByVal TableName As String) ' Remember what we're binding to m_Columns = Columns m_dtGrid = dtGrid m_dvGrid = m_dtGrid.DefaultView ' Use the default view from the table m_Grid = Grid m_BusinessLogic = BusinessLogic m_sTableName = TableName ' Link them up AddGridHandlers() End Sub #End Region #Region " Grid Events and Binding " Private Sub AddGridHandlers() AddHandler m_Grid.QueryCellInfo, AddressOf GridQueryCellInfo AddHandler m_Grid.QueryRowCount, AddressOf GridQueryRowCount AddHandler m_Grid.SaveCellInfo, AddressOf GridSaveCellInfo


MS Martin Squicciarini May 22, 2003 03:02 PM UTC

I just download the new verison 1.5.2 and when use the object browser to look at the sig of CurrentCellShowedDropDown is use System.EventArgs not GridCurrentCellShowingDropDownEventArgs. Is that a bug? The sig from the object browser is CurrentCellShowedDropDown(ByVal sender As Object, ByVal e As System.EventArgs)


MS Martin Squicciarini May 22, 2003 03:44 PM UTC

I get the sample to load but the problem is now the datetime. Dim dt As DateTime = CType(cc.Renderer.ControlValue, DateTime) does not work becasue the date string is "yyyyMMdd" and it does not convert. Is there a way to convert this or do I have to do it manually (strip the date apart and covert it to a format that DataTime reconizes).


AD Administrator Syncfusion Team May 22, 2003 07:13 PM UTC

As I said earlier, the code I uploaded requires the 1.6 beta. It will not work with the 1.5.2.0 that you downloaded. To get 1.6 beta, submit a support incident and request it. if s holds a date in format "yyyyMMdd", you can get a DateTime object d from it using DateTimeParseExact. Dim d As DateTime = DateTime.ParseExact(s, "yyyyMMdd", null, System.Globalization.DateTimeStyles.None)


MS Martin Squicciarini May 23, 2003 10:08 AM UTC

Clay, Thanks for the reply with the ParseExact method. I did miss the fact that I needed V1.6 to run the sample.

Loader.
Live Chat Icon For mobile
Up arrow icon