This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
ChildForm.vb
57 lines (56 loc) · 2.12 KB
/
ChildForm.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
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports DevExpress.Utils
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Base
Namespace DevExpress.Samples.DocumentSelector
Partial Public Class ChildForm
Inherits XtraForm
Public Sub New()
InitializeComponent()
End Sub
Private Shared groupIndex As Integer = 0
Private Sub Form2_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
AddHandler gridView1.FocusedRowChanged, AddressOf Form2_FocusedRowChanged
Dim photos As IList(Of Photo) = New List(Of Photo)()
Dim group() As Integer = photoGroups((groupIndex) Mod photoGroups.Length)
groupIndex += 1
For i As Integer = 0 To group.Length - 1
photos.Add(New Photo(String.Format("Photo{0}", group(i)), String.Format("Images\0{0}.jpg", group(i))))
Next i
gridControl1.DataSource = photos
gridView1.BestFitColumns()
End Sub
Private Sub Form2_FocusedRowChanged(ByVal sender As Object, ByVal e As FocusedRowChangedEventArgs)
If e.FocusedRowHandle = GridControl.InvalidRowHandle Then
Return
End If
pictureBox1.Image = LoadImage(CStr(gridView1.GetRowCellValue(e.FocusedRowHandle, "Path")))
End Sub
Private Shared Function LoadImage(ByVal path As String) As System.Drawing.Image
Dim currentAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetAssembly(GetType(ChildForm))
Return ResourceImageHelper.CreateImageFromResources("DevExpress.Samples.DocumentSelector." & path.Replace("\", "."), currentAssembly)
End Function
Private Shared photoGroups()() As Integer = { New Integer() { 5, 3, 7 }, New Integer() { 3, 4 }, New Integer() { 2, 3, 4, 5 }, New Integer() { 0, 1, 6, 8 } }
End Class
Friend Class Photo
Public Sub New(ByVal name As String, ByVal path As String)
nameCore = name
pathCore = path
End Sub
Private nameCore As String
Private pathCore As String
Public ReadOnly Property Name() As String
Get
Return nameCore
End Get
End Property
Public ReadOnly Property Path() As String
Get
Return pathCore
End Get
End Property
End Class
End Namespace