You can hide the drop-down button in the date time picker cell by setting the DateTimePickerCell.ShowDropDownButton property to NotShown and the DateTimePickerCell.ShowUpDown to True. In this case the spin button is shown instead of the drop-down button while editing a cell, so you may wish to adjust the position of the spin button in code in order to hide it.
Using Code
The following code creates a user-defined cell, DateCell, that inherits the date time picker cell.
[VB]
Imports GrapeCity.Win.MultiRow
Public Class DateCell
Inherits DateTimePickerCell
Public Sub New()
Me.ShowDropDownButton = CellButtonVisibility.NotShown
Me.ShowUpDown = True
End Sub
Protected Overrides Function GetEditingControlBounds(ByVal cellBounds As Rectangle, ByVal rowIndex As Integer) As Rectangle
Return New Rectangle(cellBounds.Location, New Size(cellBounds.Width + SystemInformation.VerticalScrollBarWidth, cellBounds.Height))
End Function
End Class
|
[CS]
using System.Drawing;
using System.Windows.Forms;
using GrapeCity.Win.MultiRow;
public class DateCell : DateTimePickerCell
{
public DateCell()
{
this.ShowDropDownButton = CellButtonVisibility.NotShown;
this.ShowUpDown = true;
}
protected override Rectangle GetEditingControlBounds(Rectangle cellBounds, int rowIndex)
{
return new Rectangle(cellBounds.Location, new Size(cellBounds.Width + SystemInformation.VerticalScrollBarWidth, cellBounds.Height));
}
}
|
Using the Designer
Use the following steps to use the date cell in the designer.
- Save the above code in a file such as DateCell.vb or DateCell.cs.
- Add the file to the project.
- Build the project.
- Open the template designer.
- Select "DateCell" from the toolbox and place it on the designer by dragging it.
Using Code
This example creates a date cell.
[VB]
Imports GrapeCity.Win.MultiRow
Dim dateCell1 As New DateCell()
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() { dateCell1 })
GcMultiRow1.RowCount = 10
|
[CS]
using GrapeCity.Win.MultiRow;
DateCell dateCell1 = new DateCell();
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { dateCell1 });
gcMultiRow1.RowCount = 10;
|
See Also