blah blah blah is here! blah blah » Close

up0down
link

public class NullableDateTimePicker : System.Windows.Forms.DateTimePicker
{
// Default Constructor
public NullableDateTimePicker() : base()
{
base.Format = DateTimePickerFormat.Custom;
NullValue = " ";
Format = DateTimePickerFormat.Custom;
CustomFormat = "dd MMM yyyy";

this.DataBindings.CollectionChanged += new CollectionChangeEventHandler(DataBindings_CollectionChanged);
}
}




//NullableDateTimePicker is the class from which DateTimePickerEditingControl class inherits.
//IDataGridViewEditingControl is the interface which DateTimePickerEditingControl class implements.
class DateTimePickerEditingControl : NullableDateTimePicker, IDataGridViewEditingControl
{
//Constructor
public DateTimePickerEditingControl()
{
this.Format = DateTimePickerFormat.Custom;
this.CustomFormat = "dd MMM yyyy";
}
}

last answered one year ago

1 answers

up0down
link

It's difficult to translate snippets like this, particularly when they appear to be incomplete but, for the first one, try this:

Public Class NullableDateTimePicker
Inherits System.Windows.Forms.DateTimePicker

Rem there needs to be a field or property for this to compile
Public ReadOnly NullValue As String

Rem Default Constructor
Public Sub New()
MyBase.New()
MyBase.Format = DateTimePickerFormat.Custom
NullValue = " "
Format = DateTimePickerFormat.Custom
CustomFormat = "dd MMM yyyy"
AddHandler Me.DataBindings.CollectionChanged, AddressOf DataBindings_CollectionChanged
End Sub

Rem need an event handler here
Private Sub DataBindings_CollectionChanged(ByVal Sender As Object, ByVal e As System.ComponentModel.CollectionChangeEventArgs)
Rem some code may need to be added in here
End Sub

End Class

and for the second one:

Rem interface and its members need defining somewhere
Interface IDataGridViewEditingControl

End Interface

Rem NullableDateTimePicker is the class from which DateTimePickerEditingControl class inherits.
Rem IDataGridViewEditingControl is the interface which DateTimePickerEditingControl class implements.
Class DateTimePickerEditingControl
Inherits NullableDateTimePicker
Implements IDataGridViewEditingControl

Rem Constructor
Public Sub DateTimePickerEditingControl()
Me.Format = DateTimePickerFormat.Custom
Me.CustomFormat = "dd MMM yyyy"
End Sub

Rem need to be implement interface members

End Class


EDIT - changed comments to use old Rem keyword in hope it will format better on this site

Feedback