BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
//To set the format for the time
this.gridGroupingControl1.TableDescriptor.Columns["DateTime"].Appearance.AnyRecordFieldCell.Format = "HH:MM"; |
//Event Customization
private void GridGroupingControl1_QueryCellStyleInfo(object sender,GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.RowIndex > 0 && e.TableCellIdentity.Column !=null && e.TableCellIdentity.Column.Name == "DateTime" && e.Style.CellType !="ColumnHeaderCell")
{
//To set the format for the time
e.Style.Format = "HH:MM";
}
} |
Thanks, it works on this way. But there is another thing. Now it appears dropdown button and when I click on it the calendar appears.
How to show time picker instead of calendar? Or even better how to set automatically current time in cell while adding new row?
Query |
Response |
Now it appears dropdown button and when I click on it the calendar appears.
How to show time picker instead of calendar? |
By default, the DateTime column will be added as MonthCalendar in GridGroupingControl. We regret to let you know that the GridGroupingControl does not have the support to customize the DateTime drop down to select only the time value.
Note:
The dropdown button can be hidden by using ShowButtons property of GridStyleInfo. Please refer to below code,
//To hidde the drop down button
this.gridGroupingControl1.TableDescriptor.Columns["DateTime"].Appearance.AnyRecordFieldCell.ShowButtons = GridShowButtons.Hide;
|
Or even better how to set automatically current time in cell while adding new row? |
Suggestion 1
In order to add the current time in the AddNewRecord row, the ShowDefaultValuesInAddNewRecord property can be set to true and the DefaultValue property can be used to set the default value on the AddNewRecord row. The default value can be updated by using the CurrentRecordContextChange event. Please refer to the below code and sample,
//To Show the default value on AddNewRecord row
this.gridGroupingControl1.ShowDefaultValuesInAddNewRecord = true;
//By using CurrentRecordContextChange event
private void GridGroupingControl1_CurrentRecordContextChange(object sender,CurrentRecordContextChangeEventArgs e)
{
if(e.Table.CurrentRecord != null && e.Table.CurrentRecord.Kind == DisplayElementKind.AddNewRecord)
{
//To set the default value
this.gridGroupingControl1.TableDescriptor.Fields["DateTime"].DefaultValue =DateTime.Now.ToShortTimeString();
}
}
|
Suggestion 2
The TableControlCurrentCellMoved event can also be used to update the time in AddNewRecordRow. Please refer to the below code and sample,
//By using TableControlCurrentCellMoved event
private void GridGroupingControl1_TableControlCurrentCellMoving(object sender,GridTableControlCurrentCellMovingEventArgs e)
{
if(e.TableControl.Table.CurrentRecord != null && e.TableControl.Table.CurrentRecord.Kind ==DisplayElementKind.AddNewRecord)
{
//To set the default value
this.gridGroupingControl1.TableDescriptor.Fields["DateTime"].DefaultValue =DateTime.Now.ToShortTimeString();
}
}
|
Thanks for support! Problem solved!