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.

Dropdown calendar events

Thread ID:

Created:

Updated:

Platform:

Replies:

4622 May 21,2003 12:07 PM May 23,2003 06:08 AM Windows Forms 9
loading
Tags: GridControl
Martin Squicciarini
Asked On May 21, 2003 12:07 PM

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.

Administrator [Syncfusion]
Replied On May 21, 2003 03:56 PM

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

Martin Squicciarini
Replied On May 22, 2003 07:27 AM

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

Administrator [Syncfusion]
Replied On May 22, 2003 07:42 AM

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.

Administrator [Syncfusion]
Replied On May 22, 2003 08:23 AM

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.

Martin Squicciarini
Replied On May 22, 2003 08:29 AM

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

Martin Squicciarini
Replied On May 22, 2003 11:02 AM

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)

Martin Squicciarini
Replied On May 22, 2003 11:44 AM

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).

Administrator [Syncfusion]
Replied On May 22, 2003 03:13 PM

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)

Martin Squicciarini
Replied On May 23, 2003 06:08 AM

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

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.

;