jj: double click to confirm, leftbound columns, fix list(obj) -> list(str) error
This commit is contained in:
parent
ddd98522cc
commit
159c8a6924
@ -597,7 +597,7 @@ Public Class frmIndex
|
||||
Dim result = frm.ShowDialog()
|
||||
|
||||
If result = DialogResult.OK Then
|
||||
Dim values As List(Of Object) = frm.SelectedValues
|
||||
Dim values As List(Of String) = frm.SelectedValues
|
||||
gridLookup.Properties.DataSource = values
|
||||
gridLookup.Properties.NullText = IIf(values.Count = 0, LOOKUP_NO_RECORDS, String.Format(LOOKUP_N_RECORDS, values.Count))
|
||||
End If
|
||||
@ -620,7 +620,7 @@ Public Class frmIndex
|
||||
frm.MultiSelect = False
|
||||
frm.DataSource = table
|
||||
frm.StartPosition = FormStartPosition.Manual
|
||||
frm.SelectedValues = New List(Of Object) From {textBox.Text}
|
||||
frm.SelectedValues = New List(Of String) From {textBox.Text}
|
||||
frm.Location = pnlIndex.PointToScreen(New Point(340, y))
|
||||
|
||||
Dim result = frm.ShowDialog()
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DevExpress.XtraGrid.Columns
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
|
||||
Public Class frmLookupGrid
|
||||
@ -6,9 +7,8 @@ Public Class frmLookupGrid
|
||||
Public Property AddNewValues As Boolean
|
||||
Public Property PreventDuplicates As Boolean
|
||||
Public Property DataSource As DataTable
|
||||
Public Property SelectedValues As List(Of Object)
|
||||
Public Property SelectedValues As List(Of String)
|
||||
|
||||
Private originalValues As List(Of Object)
|
||||
Private dataColumn As Integer
|
||||
|
||||
Private view As GridView
|
||||
@ -38,6 +38,12 @@ Public Class frmLookupGrid
|
||||
dataColumn = 0
|
||||
End If
|
||||
|
||||
' Alle Spalten linksbündig formatieren
|
||||
For columnIndex = dataColumn To DataSource.Columns.Count - 1
|
||||
Dim column As GridColumn = view.Columns.Item(columnIndex)
|
||||
column.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near
|
||||
Next
|
||||
|
||||
If AddNewValues Then
|
||||
view.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.True
|
||||
view.OptionsView.NewItemRowPosition = NewItemRowPosition.Top
|
||||
@ -48,12 +54,9 @@ Public Class frmLookupGrid
|
||||
|
||||
' Wenn Selected Values nicht gesetzt ist, leere Liste anlegen
|
||||
If SelectedValues Is Nothing Then
|
||||
SelectedValues = New List(Of Object)
|
||||
SelectedValues = New List(Of String)
|
||||
End If
|
||||
|
||||
' Ursprüngliche Werte zwischenspeichern
|
||||
originalValues = SelectedValues
|
||||
|
||||
' Bereits ausgewählte Werte im grid auswählen
|
||||
SyncItemsWithView(view)
|
||||
|
||||
@ -89,12 +92,12 @@ Public Class frmLookupGrid
|
||||
view.FindFilterText = String.Empty
|
||||
|
||||
If MultiSelect Then
|
||||
Dim values As New List(Of Object)
|
||||
Dim values As New List(Of String)
|
||||
|
||||
For index = 0 To viewLookup.DataRowCount - 1
|
||||
Dim row As DataRow = view.GetDataRow(index)
|
||||
Dim selected As Boolean = row.Item(0)
|
||||
Dim value As Object = row.Item(1)
|
||||
Dim value As String = row.Item(1)
|
||||
|
||||
If selected Then
|
||||
values.Add(value)
|
||||
@ -112,7 +115,7 @@ Public Class frmLookupGrid
|
||||
Dim row As DataRow = view.GetDataRow(rowHandle)
|
||||
Dim value = row.Item(0)
|
||||
|
||||
SelectedValues = New List(Of Object) From {value}
|
||||
SelectedValues = New List(Of String) From {value}
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@ -147,4 +150,27 @@ Public Class frmLookupGrid
|
||||
e.Cancel = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub viewLookup_RowClick(sender As Object, e As RowClickEventArgs) Handles viewLookup.RowClick
|
||||
' If user double-clicks on a row
|
||||
If e.Clicks = 2 And e.Button = MouseButtons.Left Then
|
||||
' And clicked row is a normal row
|
||||
If e.RowHandle >= 0 Then
|
||||
' If multiselect is true, check the current row
|
||||
' If multiselect is false, select the current row and close the window
|
||||
If MultiSelect = True Then
|
||||
Dim row As DataRow = view.GetDataRow(e.RowHandle)
|
||||
row.Item(0) = Not CBool(row.Item(0))
|
||||
Else
|
||||
Dim row As DataRow = view.GetDataRow(e.RowHandle)
|
||||
Dim value = row.Item(0)
|
||||
|
||||
SelectedValues = New List(Of String) From {value}
|
||||
|
||||
DialogResult = DialogResult.OK
|
||||
Close()
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Loading…
x
Reference in New Issue
Block a user