This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.vb
85 lines (74 loc) · 2.79 KB
/
Main.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
' Developer Express Code Central Example:
' How to use TypeConverter for converting values displayed in a LookUpEdit dropdown
'
' LookUpEdit does not support this functionality. However, you can accomplish this
' task by creating an unbound column
' (ms-help://DevExpress.NETv10.2/DevExpress.WindowsForms/CustomDocument1477.htm)
' and by using GridLookUpEdit
' (ms-help://DevExpress.NETv10.2/DevExpress.WindowsForms/clsDevExpressXtraEditorsGridLookUpEdittopic.htm)
' instead. This example illustrates how it can be done.
'
' You can find sample updates and versions for different programming languages here:
' http://www.devexpress.com/example=E2814
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraEditors
Imports DevExpress.XtraBars
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraBars.Ribbon.Helpers
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DevExpress.Utils
Imports DevExpress.XtraGrid.Columns
Imports System.Collections
Imports DevExpress.XtraEditors.Repository
Namespace DXSample
Partial Public Class Main
Inherits XtraForm
Public Sub New()
InitializeComponent()
End Sub
Private list As BindingList(Of MyObject), gridList As BindingList(Of MyObject)
Private helper As TypeConverterHelper
Public Sub InitData()
list = New BindingList(Of MyObject)()
list.Add(New MyObject(1, "A", New Point(1, 1)))
list.Add(New MyObject(2, "B", New Point(2, 3)))
list.Add(New MyObject(3, "C", New Point(4, 5)))
list.Add(New MyObject(4, "D", New Point(6, 7)))
list.Add(New MyObject(5, "E", New Point(8, 9)))
gridList = New BindingList(Of MyObject)()
gridList.Add(New MyObject(1, "A", New Point(1, 1)))
gridList.Add(New MyObject(2, "B", New Point(2, 3)))
gridList.Add(New MyObject(3, "C", New Point(4, 5)))
End Sub
Private Sub OnFormLoad(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
InitData()
Dim edit As New RepositoryItemGridLookUpEdit()
gridControl1.RepositoryItems.Add(edit)
SetUpEditor(edit)
SetUpEditor(gridLookUpEdit1.Properties)
gridControl1.DataSource = gridList
gridControl1.ForceInitialize()
gridView1.Columns("ID").ColumnEdit = edit
End Sub
Private Sub SetUpEditor(ByVal edit As RepositoryItemGridLookUpEdit)
edit.DataSource = list 'new BindingSource(list, "");
edit.ValueMember = "ID"
edit.DisplayMember = "Text"
helper = New TypeConverterHelper(edit,"Unbound", "Point")
End Sub
Protected Overrides Sub OnFormClosing(ByVal e As FormClosingEventArgs)
MyBase.OnFormClosing(e)
If helper IsNot Nothing Then
helper.RemoveUnboundColumn()
End If
End Sub
End Class
End Namespace