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
/
Form1.vb
93 lines (78 loc) · 3.05 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.BandedGrid
Imports DevExpress.XtraGrid.Columns
Namespace DXWindowsApplication5
Partial Public Class Form1
Inherits XtraForm
Public Sub New()
InitializeComponent()
AddGridView()
RegisterViewsInComboBox()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
' TODO: This line of code loads data into the 'countriesDBDataSet.Countries' table. You can move, or remove it, as needed.
Me.countriesTableAdapter.Fill(Me.countriesDBDataSet.Countries)
End Sub
Private myGridView As GridView
Private Sub AddGridView()
myGridView = New GridView(gridControl1)
myGridView.ViewCaption = "Table"
Dim fieldNames() As String = { "Country", "Capital", "Currency", "Religions", "Area", "Population", "GDP", "Languages" }
For Each fieldName As String In fieldNames
Dim column As GridColumn = myGridView.Columns.AddField(fieldName)
column.Visible = True
Next fieldName
End Sub
Private Sub RegisterViewsInComboBox()
comboView.Items.Add("Auto")
For Each view As BaseView In gridControl1.ViewCollection
comboView.Items.Add(view.ViewCaption)
Next view
comboViewTypeItem.EditValue = gridControl1.ViewCollection(0).ViewCaption
End Sub
Private Sub barComboItem_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles comboViewTypeItem.EditValueChanged
Dim comboBox As ComboBoxEdit = TryCast(barManager.ActiveEditor, ComboBoxEdit)
If comboBox Is Nothing Then
Return
End If
If comboBox.EditValue.ToString() = "Auto" Then
SetAutoView()
Else
Dim selectedView As BaseView = gridControl1.ViewCollection(comboBox.SelectedIndex - 1)
gridControl1.MainView = selectedView
End If
End Sub
Private Sub gridControl1_Resize(ByVal sender As Object, ByVal e As EventArgs) Handles gridControl1.Resize
If comboViewTypeItem.EditValue.ToString() <> "Auto" Then
Return
End If
SetAutoView()
End Sub
Private Sub SetAutoView()
If gridControl1.Width < 700 Then
gridControl1.MainView = layoutView1
Else
gridControl1.MainView = myGridView
End If
End Sub
Private Sub gridControl1_DefaultViewChanged(ByVal sender As Object, ByVal e As EventArgs) Handles gridControl1.DefaultViewChanged
checkShowFooter.Enabled = TypeOf gridControl1.MainView Is GridView
If checkShowFooter.Enabled Then
checkShowFooter.Checked = (TryCast(gridControl1.MainView, GridView)).OptionsView.ShowFooter
Else
checkShowFooter.Checked = False
End If
End Sub
Private Sub checkShowFooter_CheckedChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles checkShowFooter.CheckedChanged
If TypeOf gridControl1.MainView Is GridView Then
TryCast(gridControl1.MainView, GridView).OptionsView.ShowFooter = checkShowFooter.Checked
End If
End Sub
End Class
End Namespace