Files
TestEIn/SelectMulti.vb
T
Dario Sassi 1dfa30a125 TestEIn 1.6u5 :
- aggiornamento.
2016-09-26 14:40:48 +00:00

95 lines
2.9 KiB
VB.net

Imports System.Windows.Forms
Imports TestEIn.EgtInterface
Public Class SelectMulti
Dim m_vId As List(Of Integer)
Dim m_nCurrEnt As Integer
Public Sub New(vId As List(Of Integer))
' This call is required by the designer.
InitializeComponent()
' Assegno la lista di Id
m_vId = vId
End Sub
Private Sub SelectMulti_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ListBox1.BeginUpdate()
' Inserisco le entità della lista
If Not IsNothing(m_vId) Then
For Each nId As Integer In m_vId
Dim bSel As Boolean = EgtIsSelectedObj(nId)
Dim sTitle As String = String.Empty
EgtGetTitle(nId, sTitle)
Dim sText As String = String.Empty
Dim sName As String = String.Empty
If EgtGetName(nId, sName) Then
sText = sName & If(bSel, "* (", " (") & sTitle & " " + nId.ToString & ")"
Else
sText = sTitle & If(bSel, "* ", " ") & nId.ToString
End If
Dim smItem As New SelMulItem(sText, nId)
ListBox1.Items.Add(smItem)
Next
End If
'Inserisco None per non selezionare alcunchè
Dim smNone As New SelMulItem("None", GDB_ID.NULL)
ListBox1.Items.Add(smNone)
ListBox1.EndUpdate()
m_nCurrEnt = GDB_ID.NULL
ListBox1.SelectedIndex = 0
End Sub
Private Sub SelectMulti_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
EgtResetMark(m_nCurrEnt)
EgtDraw()
End Sub
Public Function GetId() As Integer
Return m_nCurrEnt
End Function
Private Sub OK_Click(sender As System.Object, e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub
Private Sub ListBox1_KeyDown(ByVal sender As System.Object, ByVal e As KeyEventArgs) Handles Me.KeyDown
If e.KeyData = Keys.Escape Then
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
EgtResetMark(m_nCurrEnt)
m_nCurrEnt = ListBox1.SelectedItem.m_nId
EgtSetMark(m_nCurrEnt)
EgtDraw()
End Sub
Private Class SelMulItem
Public m_sTitle As String
Public m_nId As Integer
Public Sub New(ByVal sTitle As String, ByVal nId As Integer)
Me.m_sTitle = sTitle
Me.m_nId = nId
End Sub
Public Overrides Function ToString() As String
Return m_sTitle
End Function
End Class
End Class