Hello.
I'm tring to make a custom cell with radtimepickerelement but something is not working in SetContentCore because any value I set in the timepicker editor when i see the value it's always nothing.
And in the other hand I can't use the custom editor in the row witch is used for add new rows in the grid.
I've done a sample code if you could help me
Thx.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim colnombre As New GridViewTextBoxColumn("nombre")
Dim colHora As New TimePickerColumn("hora")
GVPrueba.Columns.Add(colnombre)
GVPrueba.Columns.Add(colHora)
GVPrueba.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
End Sub
Private Sub GVPrueba_SelectionChanged(sender As Object, e As EventArgs) Handles GVPrueba.SelectionChanged
If GVPrueba.SelectedRows.Count = 1 Then
If GVPrueba.SelectedRows(0).Cells("hora").Value IsNot Nothing Then
MsgBox(GVPrueba.SelectedRows(0).Cells("hora").Value.ToString)
End If
End If
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
If GVPrueba.Rows.Count > 0 Then
GVPrueba.Rows(0).Cells("hora").Value = Now
End If
End Sub
Public Class TimePickerCellElement
Inherits GridDataCellElement
Public Sub New(ByVal column As GridViewColumn, ByVal row As GridRowElement)
MyBase.New(column, row)
End Sub
Private oRadTimePickerElement As RadTimePickerElement
Protected Overrides Sub CreateChildElements()
MyBase.CreateChildElements()
oRadTimePickerElement = New RadTimePickerElement()
Me.Children.Add(oRadTimePickerElement)
End Sub
Protected Overrides Sub SetContentCore(value As Object)
If Me.Value IsNot Nothing AndAlso Me.Value IsNot DBNull.Value Then
DateTime.TryParse(value, oRadTimePickerElement.Value)
' MyBase.SetContentCore(value)
End If
End Sub
Public Overrides Function IsCompatible(ByVal data As GridViewColumn, ByVal context As Object) As Boolean
Return TypeOf data Is TimePickerColumn AndAlso (TypeOf context Is GridDataRowElement OrElse TypeOf context Is GridNewRowElement)
End Function
End Class
Public Class TimePickerColumn
Inherits GridViewDataColumn
Public Sub New(ByVal fieldName As String)
MyBase.New(fieldName)
End Sub
Public Overrides Function GetCellType(ByVal row As GridViewRowInfo) As Type
If TypeOf row Is GridViewDataRowInfo Then
Return GetType(TimePickerCellElement)
End If
Return MyBase.GetCellType(row)
End Function
End Class