). First column has DataSource like "Combo1", "Combo2" and "Date". First and second values must populate second cell with different
Public Class RadForm1
Dim Condit As System.Collections.ArrayList
Dim CbValue1 As System.Collections.ArrayList
Dim CbValue2 As System.Collections.ArrayList
Private Sub RadForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Condit = New System.Collections.ArrayList
Condit.Add("Combo1")
Condit.Add("Combo2")
Condit.Add("Date")
CbValue1 = New System.Collections.ArrayList
CbValue1.Add("C1_1")
CbValue1.Add("C1_2")
CbValue2 = New System.Collections.ArrayList
CbValue2.Add("C2_1")
CbValue2.Add("C2_2")
Dim column As Telerik.WinControls.UI.GridViewComboBoxColumn
column = gridLogic.Columns(0)
column.DataType = GetType(String)
column.DataSource = Condit
column = gridLogic.Columns(1)
column.DataType = GetType(String)
column.DataSource = CbValue1
gridLogic.Rows.AddNew()
gridLogic.Rows(0).Cells(0).Value = "Combo1"
gridLogic.Rows(0).Cells(1).Value = "C1_1"
gridLogic.Rows.AddNew()
gridLogic.Rows(1).Cells(0).Value = "Combo1"
gridLogic.Rows(1).Cells(1).Value = "C1_2"
gridLogic.Rows.AddNew()
gridLogic.Rows(2).Cells(0).Value = "Combo1"
gridLogic.Rows(2).Cells(1).Value = "C1_1"
End Sub
Private Sub gridLogic_CellBeginEdit(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellCancelEventArgs) Handles gridLogic.CellBeginEdit
Dim NumRow As Integer = gridLogic.Rows.IndexOf(gridLogic.CurrentRow)
If gridLogic.Columns(1).IsCurrent AndAlso gridLogic.Rows(NumRow).Cells(0).Value = "Date" Then
If gridLogic.Rows(NumRow).Cells(1).CellElement.Children.Count = 0 Then
Dim dtel As New Telerik.WinControls.UI.RadDateTimeEditorElement
AddHandler dtel.ValueChanged, AddressOf gridlogic_DateTime_ValueChanged
dtel.Tag = NumRow
dtel.Value = Now
gridLogic.Rows(NumRow).Cells(1).CellElement.Children.Add(dtel)
e.Cancel = True
Else
e.Cancel = True
End If
End If
If gridLogic.Columns(0).IsCurrent Then
Dim editor As Telerik.WinControls.UI.IInputEditor = Me.gridLogic.ActiveEditor
If TypeOf (editor) Is Telerik.WinControls.UI.RadDropDownListEditor Then
Dim comboElement As Telerik.WinControls.UI.RadDropDownListEditorElement = CType(CType(editor, Telerik.WinControls.UI.RadDropDownListEditor).EditorElement, Telerik.WinControls.UI.RadDropDownListEditorElement)
AddHandler (comboElement.SelectedIndexChanged), AddressOf gridlogic_Condition_SelectedIndexChanged
End If
End If
End Sub
Private Sub gridlogic_Condition_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As EventArgs)
Dim NumRow As Integer = gridLogic.Rows.IndexOf(gridLogic.CurrentRow)
Dim NumCol As Integer = gridLogic.Columns.IndexOf(gridLogic.CurrentColumn)
If CType(sender, Telerik.WinControls.UI.RadDropDownListEditorElement).SelectedIndex < 0 Then Exit Sub
Dim item As String = CType(sender, Telerik.WinControls.UI.RadDropDownListEditorElement).SelectedItem.Value
If item = "Combo1" Then
If gridLogic.Rows(NumRow).Cells(1).CellElement.Children.Count > 0 Then
If Not TypeOf gridLogic.Rows(NumRow).Cells(1).CellElement.Children(0) Is Telerik.WinControls.UI.RadDropDownListEditorElement Then
gridLogic.Rows(NumRow).Cells(1).CellElement.Children.Remove(gridLogic.Rows(NumRow).Cells(1).CellElement.Children(0))
End If
End If
gridLogic.Rows(NumRow).Cells(1).Value = "C1_1"
End If
If item = "Combo2" Then
If gridLogic.Rows(NumRow).Cells(1).CellElement.Children.Count > 0 Then
If Not TypeOf gridLogic.Rows(NumRow).Cells(1).CellElement.Children(0) Is Telerik.WinControls.UI.RadDropDownListEditorElement Then
gridLogic.Rows(NumRow).Cells(1).CellElement.Children.Remove(gridLogic.Rows(NumRow).Cells(1).CellElement.Children(0))
End If
End If
gridLogic.Rows(NumRow).Cells(1).Value = "C2_1"
End If
If item = "Date" Then
If gridLogic.Rows(NumRow).Cells(1).CellElement.Children.Count = 0 Then
Dim dtel As New Telerik.WinControls.UI.RadDateTimeEditorElement
AddHandler dtel.ValueChanged, AddressOf gridlogic_DateTime_ValueChanged
dtel.Tag = NumRow
Try
dtel.Value = Now
Catch ex As Exception
End Try
gridLogic.Rows(NumRow).Cells(1).CellElement.Children.Add(dtel)
End If
End If
End Sub
Private Sub gridlogic_DateTime_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim dt As Telerik.WinControls.UI.RadDateTimeEditorElement = CType(sender, Telerik.WinControls.UI.RadDateTimeEditorElement)
gridLogic.Rows(dt.Tag).Cells(1).Value = dt.Value
End Sub
Private Sub gridLogic_CellEndEdit(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles gridLogic.CellEndEdit
If gridLogic.Columns(0).IsCurrent Then
Dim editor As Telerik.WinControls.UI.IInputEditor = Me.gridLogic.ActiveEditor
If TypeOf (editor) Is Telerik.WinControls.UI.RadDropDownListEditor Then
Dim comboElement As Telerik.WinControls.UI.RadDropDownListEditorElement = CType(CType(editor, Telerik.WinControls.UI.RadDropDownListEditor).EditorElement, Telerik.WinControls.UI.RadDropDownListEditorElement)
RemoveHandler (comboElement.SelectedIndexChanged), AddressOf gridlogic_Condition_SelectedIndexChanged
End If
End If
End Sub
Private Sub gridLogic_CellEditorInitialized(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles gridLogic.CellEditorInitialized
If gridLogic.Columns(1).IsCurrent Then
If gridLogic.CurrentRow.Cells(0).Value = "Combo1" Or gridLogic.CurrentRow.Cells(0).Value = "Combo2" Then
Dim NumRow As Integer = gridLogic.Rows.IndexOf(gridLogic.CurrentRow)
Dim editor As Telerik.WinControls.UI.RadDropDownListEditor = gridLogic.ActiveEditor
Dim editorElement As Telerik.WinControls.UI.RadDropDownListEditorElement = editor.EditorElement
If gridLogic.CurrentRow.Cells(0).Value = "Combo1" Then
editorElement.DataSource = CbValue1
editorElement.SelectedText = "C1_1"
End If
If gridLogic.CurrentRow.Cells(0).Value = "Combo2" Then
editorElement.DataSource = CbValue2
editorElement.SelectedText = "C2_1"
End If
End If
End If
End Sub
End Class
. But I can not obtain
from specific cell to change editor (from DropDownList to DateTimeEditor, or remove DateTimeEditor).
How can I change code? Is here some simplier way to obtain result (described above)?