Hi Admin,
I want to know how to change font for dropdownlist and I put valuemember and displaymember for dropdownlist but after I choose gridview column show valuemember but I don't want . I want dispalymember. One column will be datatime column or textbox column or dropdownlist.
Below My coding .
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports Telerik.WinControls.UI
Public Class RadForm1
Private Sub RadForm1_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
With RadGridView1.Columns
.Add(New GridViewTextBoxColumn("EntityFilingDetailsID") With {.HeaderText = "EntityFilingDetailsID", .IsVisible = False, .VisibleInColumnChooser = False})
.Add(New GridViewTextBoxColumn("ReportHeading") With {.HeaderText = "Report Heading"})
.Add(New GridViewTextBoxColumn("FilingDetail") With {.HeaderText = "Filing Detail"})
.Add(New GridViewTextBoxColumn("EntityFilingValue") With {.HeaderText = "EntityFilingValue"})
.Add(New GridViewTextBoxColumn("Editor") With {.HeaderText = "EntityFilingValue", .IsVisible = False})
.Add(New GridViewTextBoxColumn("FieldDataType") With {.HeaderText = "FieldDataType", .IsVisible = False, .VisibleInColumnChooser = False})
.Add(New GridViewTextBoxColumn("DropDownListData") With {.HeaderText = "DropDownListData", .IsVisible = False, .VisibleInColumnChooser = False})
.Add(New GridViewTextBoxColumn("IsReadOnly") With {.HeaderText = "IsReadOnly", .IsVisible = False, .VisibleInColumnChooser = False})
End With
Dim listofEntityFilingDetails As New List(Of EntityFilingDetails)
Dim entityFilingDetails As New EntityFilingDetails
entityFilingDetails.EntityFilingDetailsID = 1
entityFilingDetails.ReportHeading = "Directed and managed in BVI (Y/N)"
entityFilingDetails.FilingDetail = "Is the activity directed and managed in the Virgin Islands?"
entityFilingDetails.EntityFilingValue = "Y"
entityFilingDetails.FieldDataType = "DropDownList"
entityFilingDetails.DropdownListData = "Y | N"
entityFilingDetails.IsReadonly = False
listofEntityFilingDetails.Add(entityFilingDetails)
entityFilingDetails = New EntityFilingDetails
entityFilingDetails.EntityFilingDetailsID = 2
entityFilingDetails.ReportHeading = "Num Board Meetings"
entityFilingDetails.FilingDetail = "Number of board meetings the entity held during the financial period with relation to this activity."
entityFilingDetails.EntityFilingValue = ""
entityFilingDetails.FieldDataType = "TextBox"
entityFilingDetails.DropdownListData = ""
entityFilingDetails.IsReadonly = False
listofEntityFilingDetails.Add(entityFilingDetails)
entityFilingDetails = New EntityFilingDetails
entityFilingDetails.EntityFilingDetailsID = 3
entityFilingDetails.ReportHeading = "Financial Period Start Date (DD/MM/YYYY)"
entityFilingDetails.FilingDetail = "Financial Period Start Date"
entityFilingDetails.EntityFilingValue = ""
entityFilingDetails.FieldDataType = "DateTimePicker"
entityFilingDetails.DropdownListData = ""
entityFilingDetails.IsReadonly = False
listofEntityFilingDetails.Add(entityFilingDetails)
entityFilingDetails = New EntityFilingDetails
entityFilingDetails.EntityFilingDetailsID = 4
entityFilingDetails.ReportHeading = "Num Board Meetings"
entityFilingDetails.FilingDetail = "Number of board meetings the entity held during the financial period with relation to this activity."
entityFilingDetails.EntityFilingValue = "1"
entityFilingDetails.FieldDataType = "DropDownList"
entityFilingDetails.DropdownListData = "Countries"
entityFilingDetails.IsReadonly = True
listofEntityFilingDetails.Add(entityFilingDetails)
RadGridView1.DataSource = listofEntityFilingDetails
End Sub
Private Sub RadGridView1_EditorRequired(sender As Object, e As EditorRequiredEventArgs) Handles RadGridView1.EditorRequired
Dim dataRow As GridViewDataRowInfo = TryCast(Me.RadGridView1.CurrentRow, GridViewDataRowInfo)
If dataRow Is Nothing Then
Return
End If
Dim editor As String = Convert.ToString(dataRow.Cells("FieldDataType").Value)
Dim DropdownListData As String = Convert.ToString(dataRow.Cells("DropdownListData").Value)
Dim editorType As Type = e.EditorType
Select Case editor
Case "TextBox"
editorType = GetType(RadTextBoxEditor)
Case "DateTimePicker"
editorType = GetType(RadDateTimeEditor)
Case "DropDownList"
editorType = GetType(RadDropDownListEditor)
End Select
e.EditorType = editorType
End Sub
Private Sub radGridView1_CellEditorInitialized(sender As Object, e As GridViewCellEventArgs) Handles RadGridView1.CellEditorInitialized
If TypeOf e.ActiveEditor Is RadDropDownListEditor Then
Dim editor As RadDropDownListEditor = TryCast(e.ActiveEditor, RadDropDownListEditor)
Dim element As RadDropDownListEditorElement = TryCast(editor.EditorElement, RadDropDownListEditorElement)
Dim DropdownListData As String = Convert.ToString(RadGridView1.CurrentRow.Cells("DropdownListData").Value)
If DropdownListData = "Y | N" Then
Dim dt As DataTable = New DataTable()
dt.Columns.Add("Question")
dt.Rows.Add("Y")
dt.Rows.Add("N")
element.DataSource = dt
element.DisplayMember = "Question"
element.ValueMember = "Question"
Else
Dim dt As DataTable = New DataTable()
dt.Columns.Add("CountryName")
dt.Columns.Add("CountryID")
dt.Rows.Add("Myanmar", "1")
dt.Rows.Add("Singapore", "2")
element.DisplayMember = "CountryID"
element.ValueMember = "CountryName"
element.DataSource = dt
End If
End If
End Sub
Private Sub radGridView1_CellFormatting(ByVal sender As Object, ByVal e As CellFormattingEventArgs) Handles RadGridView1.CellFormatting
If TypeOf e.CellElement.RowInfo Is GridViewDataRowInfo AndAlso e.Column.Name = "EntityFilingValue" Then
Dim dateformat As DateTime
If e.CellElement.RowInfo.Cells("EntityFilingValue").Value IsNot Nothing Then
If DateTime.TryParse(e.CellElement.RowInfo.Cells("EntityFilingValue").Value.ToString(), dateformat) Then
e.CellElement.Text = dateformat.ToString("d MMMM yyyy")
End If
If CType(e.Row.Cells("IsReadonly").Value, Boolean) Then
e.CellElement.RowInfo.Cells("EntityFilingValue").ReadOnly = True
Else
e.CellElement.RowInfo.Cells("EntityFilingValue").ReadOnly = False
End If
End If
End If
End Sub
End Class
Public Class EntityFilingDetails
Property EntityFilingDetailsID As Integer
Property ReportHeading As String
Property FilingDetail As String
Property EntityFilingValue As String
Property FieldDataType As String
Property DropdownListData As String
Property IsReadonly As Boolean
End Class