-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
68 lines (62 loc) · 2.52 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
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.Repository
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.Utils
Namespace WindowsApplication1
Partial Public Class Form1
Inherits Form
Private r As New Random()
Public Function GetRandomValue() As Integer
Return r.Next(100) + 50
End Function
Private Function CreateTable(ByVal RowCount As Integer) As DataTable
Dim tbl As New DataTable()
tbl.Columns.Add("Name", GetType(String))
tbl.Columns.Add("UseStyles", GetType(Boolean))
tbl.Columns.Add("R", GetType(Integer))
tbl.Columns.Add("G", GetType(Integer))
tbl.Columns.Add("B", GetType(Integer))
For i As Integer = 0 To RowCount - 1
tbl.Rows.Add(New Object() { String.Format("Name{0}", i), False, GetRandomValue(), GetRandomValue(), GetRandomValue() })
Next i
Return tbl
End Function
Public Sub New()
AppearanceObject.DefaultFont = New Font(AppearanceObject.DefaultFont.FontFamily, 14, FontStyle.Bold)
InitializeComponent()
gridControl1.DataSource = CreateTable(5)
Dim riCheckEdit As New RepositoryItemCheckEdit()
gridView1.Columns("UseStyles").ColumnEdit = riCheckEdit
Dim riTrackBar As New RepositoryItemTrackBar()
riTrackBar.Maximum = 255
gridView1.Columns("R").ColumnEdit = riTrackBar
gridView1.Columns("G").ColumnEdit = riTrackBar
gridView1.Columns("B").ColumnEdit = riTrackBar
AddHandler riCheckEdit.EditValueChanged, AddressOf OnEditValueChanged
AddHandler riTrackBar.EditValueChanged, AddressOf OnEditValueChanged
AddHandler gridView1.RowCellStyle, AddressOf gridView1_RowCellStyle
End Sub
Private Sub gridView1_RowCellStyle(ByVal sender As Object, ByVal e As RowCellStyleEventArgs)
If (Not True.Equals(gridView1.GetRowCellValue(e.RowHandle, "UseStyles"))) Then
Return
End If
e.Appearance.BackColor = GetRowBackColor(e.RowHandle)
End Sub
Private Sub OnEditValueChanged(ByVal sender As Object, ByVal e As EventArgs)
gridView1.PostEditor()
End Sub
Private Function GetRowBackColor(ByVal rowHandle As Integer) As Color
Return Color.FromArgb(GetColorValue(rowHandle, "R"), GetColorValue(rowHandle, "G"), GetColorValue(rowHandle, "B"))
End Function
Private Function GetColorValue(ByVal rowHandle As Integer, ByVal fieldName As String) As Integer
Return CInt(Fix(gridView1.GetRowCellValue(rowHandle, fieldName)))
End Function
End Class
End Namespace