This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
70 lines (67 loc) · 2.64 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraEditors.Repository
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Columns
Imports System.Collections
Imports System.Globalization
Imports System.Threading
Namespace GridControlTypeConverter
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
InitLocalizibleArea()
InitGrid()
End Sub
Private helper, helper1 As TypeConverterHelper
Private objectList As New BindingList(Of MyObject)()
Private ri As New RepositoryItemTextEdit()
Private Sub InitLocalizibleArea()
comboBoxEdit1.EditValue = Thread.CurrentThread.CurrentCulture
For Each item In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
comboBoxEdit1.Properties.Items.Add(item)
Next item
For Each value In System.Enum.GetValues(GetType(MyObject.MyEnum))
Dim converter As TypeConverter = TypeDescriptor.GetConverter(value.GetType())
listBoxControl1.Items.Add(converter.ConvertToString(value))
Next value
AddHandler comboBoxEdit1.EditValueChanged, AddressOf comboBoxEdit1_EditValueChanged
AddHandler comboBoxEdit1.CustomDisplayText, AddressOf comboBoxEdit1_CustomDisplayText
End Sub
Private Sub comboBoxEdit1_CustomDisplayText(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs)
e.DisplayText = (CType(e.Value, CultureInfo)).DisplayName
End Sub
Private Sub comboBoxEdit1_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs)
listBoxControl1.Items.Clear()
Dim culture As CultureInfo = TryCast(comboBoxEdit1.EditValue, CultureInfo)
If culture IsNot Nothing Then
Thread.CurrentThread.CurrentCulture = culture
For Each value In System.Enum.GetValues(GetType(MyObject.MyEnum))
Dim converter As TypeConverter = TypeDescriptor.GetConverter(value.GetType())
listBoxControl1.Items.Add(converter.ConvertToString(value))
Next value
For i As Integer = 0 To gridView1.DataRowCount - 1
gridView1.RefreshRowCell(i, gridView1.Columns("UnboundLocalizedEnum"))
Next i
End If
End Sub
Private Sub InitGrid()
For i As Integer = 0 To 9
objectList.Add(New MyObject())
Next i
gridControl1.DataSource = objectList
gridControl2.DataSource = objectList
helper = New TypeConverterHelper("UnboundLocation", "Location",gridView2)
helper1 = New TypeConverterHelper("UnboundLocalizedEnum", "Capacity", gridView1)
End Sub
End Class
End Namespace