Public Class ColFilterEdit
Inherits System.Windows.Forms.Form
Public Abandoned As Boolean = False
Private DropDownPopulated As Boolean = False
Private gd As nbfGrid
Friend WithEvents btnClear As System.Windows.Forms.Button
Private col As Integer
#Region " Windows Form Designer generated code "
Public Sub New(ByVal SceGrid As nbfGrid, ByVal SceCol As Integer)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
gd = SceGrid
col = SceCol
AddHandler ComboBox1.DropDown, AddressOf cmbDropped
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents btnAddFilter As System.Windows.Forms.Button
Friend WithEvents btnRemFilter As System.Windows.Forms.Button
Friend WithEvents btnOK As System.Windows.Forms.Button
Friend WithEvents btnCancel As System.Windows.Forms.Button
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(ColFilterEdit))
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.btnAddFilter = New System.Windows.Forms.Button
Me.btnRemFilter = New System.Windows.Forms.Button
Me.btnOK = New System.Windows.Forms.Button
Me.btnCancel = New System.Windows.Forms.Button
Me.btnClear = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.FormattingEnabled = True
Me.ComboBox1.Location = New System.Drawing.Point(16, 40)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(144, 21)
Me.ComboBox1.Sorted = True
Me.ComboBox1.TabIndex = 0
'
'ListBox1
'
Me.ListBox1.FormattingEnabled = True
Me.ListBox1.Location = New System.Drawing.Point(232, 40)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(136, 108)
Me.ListBox1.TabIndex = 1
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(84, 13)
Me.Label1.TabIndex = 2
Me.Label1.Text = "New Filter Value"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(232, 24)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(48, 13)
Me.Label2.TabIndex = 3
Me.Label2.Text = "Filter List"
'
'btnAddFilter
'
Me.btnAddFilter.Location = New System.Drawing.Point(168, 40)
Me.btnAddFilter.Name = "btnAddFilter"
Me.btnAddFilter.Size = New System.Drawing.Size(48, 24)
Me.btnAddFilter.TabIndex = 4
Me.btnAddFilter.Text = ">>"
Me.btnAddFilter.UseVisualStyleBackColor = True
'
'btnRemFilter
'
Me.btnRemFilter.Location = New System.Drawing.Point(168, 72)
Me.btnRemFilter.Name = "btnRemFilter"
Me.btnRemFilter.Size = New System.Drawing.Size(48, 24)
Me.btnRemFilter.TabIndex = 5
Me.btnRemFilter.Text = "<<"
Me.btnRemFilter.UseVisualStyleBackColor = True
'
'btnOK
'
Me.btnOK.Location = New System.Drawing.Point(392, 40)
Me.btnOK.Name = "btnOK"
Me.btnOK.Size = New System.Drawing.Size(48, 24)
Me.btnOK.TabIndex = 6
Me.btnOK.Text = "OK"
Me.btnOK.UseVisualStyleBackColor = True
'
'btnCancel
'
Me.btnCancel.Location = New System.Drawing.Point(392, 72)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(48, 24)
Me.btnCancel.TabIndex = 7
Me.btnCancel.Text = "Cancel"
Me.btnCancel.UseVisualStyleBackColor = True
'
'btnClear
'
Me.btnClear.Location = New System.Drawing.Point(304, 16)
Me.btnClear.Name = "btnClear"
Me.btnClear.Size = New System.Drawing.Size(64, 20)
Me.btnClear.TabIndex = 8
Me.btnClear.Text = "Clear"
Me.btnClear.UseVisualStyleBackColor = True
'
'ColFilterEdit
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(464, 181)
Me.Controls.Add(Me.btnClear)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnOK)
Me.Controls.Add(Me.btnRemFilter)
Me.Controls.Add(Me.btnAddFilter)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.ComboBox1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "ColFilterEdit"
Me.Text = "Column Filter"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub btnAddFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddFilter.Click
Try
Dim cnt As Integer
For cnt = 0 To ListBox1.Items.Count - 1
If ListBox1.Items.Item(cnt) = ComboBox1.Text Then
MsgBox("Field already in list")
Exit Sub
End If
Next cnt
ListBox1.Items.Add(ComboBox1.Text)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btnRemFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemFilter.Click
Try
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Sub cmbDropped(ByVal sender As Object, ByVal e As System.EventArgs)
Try
If Not DropDownPopulated Then
'MsgBox("In drop pop")
DropDownPopulated = True
Dim cval As String
Dim lfnd As Boolean
Dim ld As Boolean = False
If gd.RowWindow.count > 0 Then
For rcnt As Integer = 0 To gd.RowWindow.count - 1
lfnd = False
Try
If gd.RowWindow.Item(rcnt).RowData.Item(col).Cached Then
cval = gd.RowWindow.Item(rcnt).RowData.Item(col).CellText
Else
If Not ld Then
ld = True
End If
cval = gd.CellTextValue(gd.RowWindow.Item(rcnt).RowData.Item(col).CellValue, col)
End If
Catch
cval = ""
End Try
If Not cval Is Nothing Then
If cval.Trim <> "" Then
For Each lst As String In ComboBox1.Items
If lst.ToUpper.Trim = cval.ToUpper.Trim Then
lfnd = True
Exit For
End If
Next
If Not lfnd Then
ComboBox1.Items.Add(cval)
End If
End If
End If
Next
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Abandoned = False
Me.Hide()
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Abandoned = True
Me.Hide()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
ListBox1.Items.Clear()
End Sub
End Class