Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Please help me with DateTimePicker ShowCheckBox property in GridView.

Please help me with DateTimePicker ShowCheckBox property in GridView.

Scheduled Pinned Locked Moved Visual Basic
help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pcphuc
    wrote on last edited by
    #1

    I got the class CalendarColumn which create DateTimePicker cell in GridView from MSDN. I try to modify this class to allow user choose ShowCheckBox in DateTimePicker or not but I am fail. Please help me the way to add this property which allow user choose to display CheckBox in DateTimePicker or not. Thanks so much! This is the class CalendarColumn : Imports System Imports System.Windows.Forms Public Class CalendarColumn Inherits DataGridViewColumn Public Sub New() MyBase.New(New CalendarCell()) End Sub Public Overrides Property CellTemplate() As DataGridViewCell Get Return MyBase.CellTemplate End Get Set(ByVal value As DataGridViewCell) ' Ensure that the cell used for the template is a CalendarCell. If (value IsNot Nothing) AndAlso _ Not value.GetType().IsAssignableFrom(GetType(CalendarCell)) _ Then Throw New InvalidCastException("Must be a CalendarCell") End If MyBase.CellTemplate = value End Set End Property End Class Public Class CalendarCell Inherits DataGridViewTextBoxCell Public Sub New() ' Use the short date format. Me.Style.Format = "d" End Sub Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, _ ByVal initialFormattedValue As Object, _ ByVal dataGridViewCellStyle As DataGridViewCellStyle) ' Set the value of the editing control to the current cell value. MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, _ dataGridViewCellStyle) Dim ctl As CalendarEditingControl = _ CType(DataGridView.EditingControl, CalendarEditingControl) ctl.Value = CType(Me.Value, DateTime) End Sub Public Overrides ReadOnly Property EditType() As Type Get ' Return the type of the editing contol that CalendarCell uses. Return GetType(CalendarEditingControl) End Get End Property Public Overrides ReadOnly Property ValueType() As Type Get ' Return the type of the value that CalendarCell contains. Return GetType(DateTime) End Get End Property Public Overrides ReadOnly Property DefaultNewRowValue() As Object Get ' Use the current date and time as the default value. Return DateTime.Now End Get End P

    R 1 Reply Last reply
    0
    • P pcphuc

      I got the class CalendarColumn which create DateTimePicker cell in GridView from MSDN. I try to modify this class to allow user choose ShowCheckBox in DateTimePicker or not but I am fail. Please help me the way to add this property which allow user choose to display CheckBox in DateTimePicker or not. Thanks so much! This is the class CalendarColumn : Imports System Imports System.Windows.Forms Public Class CalendarColumn Inherits DataGridViewColumn Public Sub New() MyBase.New(New CalendarCell()) End Sub Public Overrides Property CellTemplate() As DataGridViewCell Get Return MyBase.CellTemplate End Get Set(ByVal value As DataGridViewCell) ' Ensure that the cell used for the template is a CalendarCell. If (value IsNot Nothing) AndAlso _ Not value.GetType().IsAssignableFrom(GetType(CalendarCell)) _ Then Throw New InvalidCastException("Must be a CalendarCell") End If MyBase.CellTemplate = value End Set End Property End Class Public Class CalendarCell Inherits DataGridViewTextBoxCell Public Sub New() ' Use the short date format. Me.Style.Format = "d" End Sub Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, _ ByVal initialFormattedValue As Object, _ ByVal dataGridViewCellStyle As DataGridViewCellStyle) ' Set the value of the editing control to the current cell value. MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, _ dataGridViewCellStyle) Dim ctl As CalendarEditingControl = _ CType(DataGridView.EditingControl, CalendarEditingControl) ctl.Value = CType(Me.Value, DateTime) End Sub Public Overrides ReadOnly Property EditType() As Type Get ' Return the type of the editing contol that CalendarCell uses. Return GetType(CalendarEditingControl) End Get End Property Public Overrides ReadOnly Property ValueType() As Type Get ' Return the type of the value that CalendarCell contains. Return GetType(DateTime) End Get End Property Public Overrides ReadOnly Property DefaultNewRowValue() As Object Get ' Use the current date and time as the default value. Return DateTime.Now End Get End P

      R Offline
      R Offline
      rohitsrivastava
      wrote on last edited by
      #2

      u will take the dll of datetime picker put the datagridview1 in the toolbox and drop in the form right click of addcolumn then there are three field (1)Name (2) Type (3) header text in name write the column name , type select the type of dll ,write the name of the header

      P 1 Reply Last reply
      0
      • R rohitsrivastava

        u will take the dll of datetime picker put the datagridview1 in the toolbox and drop in the form right click of addcolumn then there are three field (1)Name (2) Type (3) header text in name write the column name , type select the type of dll ,write the name of the header

        P Offline
        P Offline
        pcphuc
        wrote on last edited by
        #3

        Thanks rohitsrivastava ! I think that is a solution. I will test for this. But how about coding to modify the class. Best regards, pvphuc

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups