-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window1.xaml.vb
71 lines (59 loc) · 2.23 KB
/
Window1.xaml.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
Imports DevExpress.Xpf.Grid
Imports System.Collections.ObjectModel
Imports System.Windows
Namespace DXGrid_NewItemRow
Partial Public Class Window1
Inherits Window
Public Sub New()
InitializeComponent()
Me.DataContext = New MyViewModel()
End Sub
Private Sub TableView_InitNewRow(ByVal sender As Object, ByVal e As InitNewRowEventArgs)
grid.SetCellValue(e.RowHandle, "UnitPrice", 10)
grid.SetCellValue(e.RowHandle, "CompanyName", "newcompany")
grid.SetCellValue(e.RowHandle, "Discontinued", False)
End Sub
Private Sub TableView_ValidateRow(ByVal sender As Object, ByVal e As GridRowValidationEventArgs)
If e.Row Is Nothing Then
Return
End If
If e.RowHandle = GridControl.NewItemRowHandle Then
e.IsValid = Not String.IsNullOrEmpty(CType(e.Row, Person).ProductName)
e.Handled = True
End If
End Sub
Private Sub TableView_InvalidRowException(ByVal sender As Object, ByVal e As InvalidRowExceptionEventArgs)
If e.RowHandle = GridControl.NewItemRowHandle Then
e.ErrorText = "Please enter the Product name. "
e.WindowCaption = "Input Error"
End If
End Sub
End Class
Public Class MyViewModel
Public Sub New()
CreateList()
End Sub
Public Property PersonList() As ObservableCollection(Of Person)
Private Sub CreateList()
PersonList = New ObservableCollection(Of Person)()
For i As Integer = 0 To 2
Dim p As New Person(i)
PersonList.Add(p)
Next i
End Sub
End Class
Public Class Person
Public Sub New()
End Sub
Public Sub New(ByVal i As Integer)
ProductName = "ProductName" & i
CompanyName = "CompanyName" & i
UnitPrice = i
Discontinued = i Mod 2 = 0
End Sub
Public Property ProductName() As String
Public Property CompanyName() As String
Public Property UnitPrice() As Integer
Public Property Discontinued() As Boolean
End Class
End Namespace