Gestione errori di configurazione camere

This commit is contained in:
Nicola Pievani
2025-07-29 18:16:36 +02:00
parent 672aed6d1c
commit 56a921fd1d
2 changed files with 123 additions and 53 deletions
+74 -45
View File
@@ -28,13 +28,13 @@ Partial Class SetConfigForm
Me.PictureBox3 = New System.Windows.Forms.PictureBox() Me.PictureBox3 = New System.Windows.Forms.PictureBox()
Me.Label1 = New System.Windows.Forms.Label() Me.Label1 = New System.Windows.Forms.Label()
Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.Label7 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label() Me.Label4 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label() Me.Label3 = New System.Windows.Forms.Label()
Me.LabelOkCfg = New System.Windows.Forms.Label() Me.LabelOkCfg = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.Label7 = New System.Windows.Forms.Label()
Me.Config = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.Config = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.ImageConfig = New System.Windows.Forms.DataGridViewImageColumn() Me.ImageConfig = New System.Windows.Forms.DataGridViewImageColumn()
Me.ComboCamera = New System.Windows.Forms.DataGridViewComboBoxColumn() Me.ComboCamera = New System.Windows.Forms.DataGridViewComboBoxColumn()
@@ -56,36 +56,41 @@ Partial Class SetConfigForm
Me.DataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None Me.DataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None
Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.DataGridView1.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.Config, Me.ImageConfig, Me.ComboCamera, Me.ImageCamera, Me.SaveConfig, Me.ApplyConfig}) Me.DataGridView1.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.Config, Me.ImageConfig, Me.ComboCamera, Me.ImageCamera, Me.SaveConfig, Me.ApplyConfig})
Me.DataGridView1.Location = New System.Drawing.Point(35, 25) Me.DataGridView1.Location = New System.Drawing.Point(47, 31)
Me.DataGridView1.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
Me.DataGridView1.Name = "DataGridView1" Me.DataGridView1.Name = "DataGridView1"
Me.DataGridView1.Size = New System.Drawing.Size(591, 159) Me.DataGridView1.RowHeadersWidth = 51
Me.DataGridView1.Size = New System.Drawing.Size(788, 196)
Me.DataGridView1.TabIndex = 0 Me.DataGridView1.TabIndex = 0
Me.DataGridView1.TabStop = False Me.DataGridView1.TabStop = False
' '
'PictureBox1 'PictureBox1
' '
Me.PictureBox1.Image = Global.My.Resources.Resources.accept Me.PictureBox1.Image = Global.My.Resources.Resources.accept
Me.PictureBox1.Location = New System.Drawing.Point(29, 48) Me.PictureBox1.Location = New System.Drawing.Point(39, 59)
Me.PictureBox1.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
Me.PictureBox1.Name = "PictureBox1" Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(29, 27) Me.PictureBox1.Size = New System.Drawing.Size(39, 33)
Me.PictureBox1.TabIndex = 1 Me.PictureBox1.TabIndex = 1
Me.PictureBox1.TabStop = False Me.PictureBox1.TabStop = False
' '
'PictureBox2 'PictureBox2
' '
Me.PictureBox2.Image = Global.My.Resources.Resources.warning Me.PictureBox2.Image = Global.My.Resources.Resources.warning
Me.PictureBox2.Location = New System.Drawing.Point(29, 83) Me.PictureBox2.Location = New System.Drawing.Point(39, 102)
Me.PictureBox2.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
Me.PictureBox2.Name = "PictureBox2" Me.PictureBox2.Name = "PictureBox2"
Me.PictureBox2.Size = New System.Drawing.Size(29, 27) Me.PictureBox2.Size = New System.Drawing.Size(39, 33)
Me.PictureBox2.TabIndex = 2 Me.PictureBox2.TabIndex = 2
Me.PictureBox2.TabStop = False Me.PictureBox2.TabStop = False
' '
'PictureBox3 'PictureBox3
' '
Me.PictureBox3.Image = Global.My.Resources.Resources.cross Me.PictureBox3.Image = Global.My.Resources.Resources.cross
Me.PictureBox3.Location = New System.Drawing.Point(29, 124) Me.PictureBox3.Location = New System.Drawing.Point(39, 153)
Me.PictureBox3.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
Me.PictureBox3.Name = "PictureBox3" Me.PictureBox3.Name = "PictureBox3"
Me.PictureBox3.Size = New System.Drawing.Size(29, 26) Me.PictureBox3.Size = New System.Drawing.Size(39, 32)
Me.PictureBox3.TabIndex = 3 Me.PictureBox3.TabIndex = 3
Me.PictureBox3.TabStop = False Me.PictureBox3.TabStop = False
' '
@@ -93,9 +98,10 @@ Partial Class SetConfigForm
' '
Me.Label1.AutoSize = True Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(134, 16) Me.Label1.Location = New System.Drawing.Point(179, 20)
Me.Label1.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label1.Name = "Label1" Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(29, 17) Me.Label1.Size = New System.Drawing.Size(35, 20)
Me.Label1.TabIndex = 4 Me.Label1.TabIndex = 4
Me.Label1.Text = "Cfg" Me.Label1.Text = "Cfg"
' '
@@ -113,20 +119,44 @@ Partial Class SetConfigForm
Me.GroupBox1.Controls.Add(Me.PictureBox1) Me.GroupBox1.Controls.Add(Me.PictureBox1)
Me.GroupBox1.Controls.Add(Me.PictureBox2) Me.GroupBox1.Controls.Add(Me.PictureBox2)
Me.GroupBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.GroupBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GroupBox1.Location = New System.Drawing.Point(35, 199) Me.GroupBox1.Location = New System.Drawing.Point(47, 245)
Me.GroupBox1.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(591, 170) Me.GroupBox1.Padding = New System.Windows.Forms.Padding(4, 4, 4, 4)
Me.GroupBox1.Size = New System.Drawing.Size(788, 209)
Me.GroupBox1.TabIndex = 5 Me.GroupBox1.TabIndex = 5
Me.GroupBox1.TabStop = False Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Legenda" Me.GroupBox1.Text = "Legenda"
' '
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label7.Location = New System.Drawing.Point(479, 153)
Me.Label7.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(131, 36)
Me.Label7.TabIndex = 11
Me.Label7.Text = "IDCamera assente" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
'
'Label6
'
Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label6.Location = New System.Drawing.Point(479, 102)
Me.Label6.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(301, 42)
Me.Label6.TabIndex = 10
Me.Label6.Text = "IDCamera non presente in elenco camere connesse" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
'
'Label5 'Label5
' '
Me.Label5.AutoSize = True Me.Label5.AutoSize = True
Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label5.Location = New System.Drawing.Point(359, 48) Me.Label5.Location = New System.Drawing.Point(479, 59)
Me.Label5.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label5.Name = "Label5" Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(119, 15) Me.Label5.Size = New System.Drawing.Size(144, 18)
Me.Label5.TabIndex = 9 Me.Label5.TabIndex = 9
Me.Label5.Text = "IDCamera connessa" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) Me.Label5.Text = "IDCamera connessa" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
' '
@@ -134,9 +164,10 @@ Partial Class SetConfigForm
' '
Me.Label4.AutoSize = True Me.Label4.AutoSize = True
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.Location = New System.Drawing.Point(74, 124) Me.Label4.Location = New System.Drawing.Point(99, 153)
Me.Label4.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label4.Name = "Label4" Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(193, 30) Me.Label4.Size = New System.Drawing.Size(232, 36)
Me.Label4.TabIndex = 8 Me.Label4.TabIndex = 8
Me.Label4.Text = "IDCamera configurazione assente" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) Me.Label4.Text = "IDCamera configurazione assente" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
' '
@@ -144,9 +175,10 @@ Partial Class SetConfigForm
' '
Me.Label3.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.Label3.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(74, 83) Me.Label3.Location = New System.Drawing.Point(99, 102)
Me.Label3.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label3.Name = "Label3" Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(295, 34) Me.Label3.Size = New System.Drawing.Size(393, 42)
Me.Label3.TabIndex = 7 Me.Label3.TabIndex = 7
Me.Label3.Text = "IDCamera configurazione già in uso in un'altra configurazione" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) Me.Label3.Text = "IDCamera configurazione già in uso in un'altra configurazione" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
' '
@@ -154,9 +186,10 @@ Partial Class SetConfigForm
' '
Me.LabelOkCfg.AutoSize = True Me.LabelOkCfg.AutoSize = True
Me.LabelOkCfg.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.LabelOkCfg.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LabelOkCfg.Location = New System.Drawing.Point(74, 48) Me.LabelOkCfg.Location = New System.Drawing.Point(99, 59)
Me.LabelOkCfg.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.LabelOkCfg.Name = "LabelOkCfg" Me.LabelOkCfg.Name = "LabelOkCfg"
Me.LabelOkCfg.Size = New System.Drawing.Size(182, 15) Me.LabelOkCfg.Size = New System.Drawing.Size(218, 18)
Me.LabelOkCfg.TabIndex = 6 Me.LabelOkCfg.TabIndex = 6
Me.LabelOkCfg.Text = "IDCamera configurazione valido" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) Me.LabelOkCfg.Text = "IDCamera configurazione valido" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
' '
@@ -164,69 +197,65 @@ Partial Class SetConfigForm
' '
Me.Label2.AutoSize = True Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(403, 16) Me.Label2.Location = New System.Drawing.Point(537, 20)
Me.Label2.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label2.Name = "Label2" Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(57, 17) Me.Label2.Size = New System.Drawing.Size(68, 20)
Me.Label2.TabIndex = 5 Me.Label2.TabIndex = 5
Me.Label2.Text = "Camera" Me.Label2.Text = "Camera"
' '
'Label6
'
Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label6.Location = New System.Drawing.Point(359, 83)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(226, 34)
Me.Label6.TabIndex = 10
Me.Label6.Text = "IDCamera non presente in elenco camere connesse" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
'
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label7.Location = New System.Drawing.Point(359, 124)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(109, 30)
Me.Label7.TabIndex = 11
Me.Label7.Text = "IDCamera assente" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
'
'Config 'Config
' '
Me.Config.FillWeight = 75.24068!
Me.Config.HeaderText = "Config" Me.Config.HeaderText = "Config"
Me.Config.MinimumWidth = 6
Me.Config.Name = "Config" Me.Config.Name = "Config"
Me.Config.ToolTipText = "iiiii" Me.Config.ToolTipText = "iiiii"
' '
'ImageConfig 'ImageConfig
' '
Me.ImageConfig.FillWeight = 53.93283!
Me.ImageConfig.HeaderText = "Result Cfg" Me.ImageConfig.HeaderText = "Result Cfg"
Me.ImageConfig.MinimumWidth = 6
Me.ImageConfig.Name = "ImageConfig" Me.ImageConfig.Name = "ImageConfig"
' '
'ComboCamera 'ComboCamera
' '
Me.ComboCamera.FillWeight = 118.042!
Me.ComboCamera.HeaderText = "ID Camera" Me.ComboCamera.HeaderText = "ID Camera"
Me.ComboCamera.MinimumWidth = 6
Me.ComboCamera.Name = "ComboCamera" Me.ComboCamera.Name = "ComboCamera"
' '
'ImageCamera 'ImageCamera
' '
Me.ImageCamera.FillWeight = 43.92786!
Me.ImageCamera.HeaderText = "Result Camera" Me.ImageCamera.HeaderText = "Result Camera"
Me.ImageCamera.MinimumWidth = 6
Me.ImageCamera.Name = "ImageCamera" Me.ImageCamera.Name = "ImageCamera"
' '
'SaveConfig 'SaveConfig
' '
Me.SaveConfig.FillWeight = 148.4289!
Me.SaveConfig.HeaderText = "SaveConfig" Me.SaveConfig.HeaderText = "SaveConfig"
Me.SaveConfig.MinimumWidth = 6
Me.SaveConfig.Name = "SaveConfig" Me.SaveConfig.Name = "SaveConfig"
' '
'ApplyConfig 'ApplyConfig
' '
Me.ApplyConfig.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill
Me.ApplyConfig.FillWeight = 160.4278!
Me.ApplyConfig.HeaderText = "ApplyConfig" Me.ApplyConfig.HeaderText = "ApplyConfig"
Me.ApplyConfig.MinimumWidth = 6
Me.ApplyConfig.Name = "ApplyConfig" Me.ApplyConfig.Name = "ApplyConfig"
' '
'SetConfigForm 'SetConfigForm
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(663, 381) Me.ClientSize = New System.Drawing.Size(884, 469)
Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.DataGridView1) Me.Controls.Add(Me.DataGridView1)
Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
Me.Name = "SetConfigForm" Me.Name = "SetConfigForm"
Me.Text = "SetConfigForm" Me.Text = "SetConfigForm"
CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
+49 -8
View File
@@ -12,6 +12,10 @@ Public Class SetConfigForm
InitializeComponent() InitializeComponent()
' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent(). ' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent().
' PopolateDataGrid()
End Sub
Private Sub LoadWindows() Handles Me.Load
PopolateDataGrid() PopolateDataGrid()
End Sub End Sub
@@ -44,8 +48,6 @@ Public Class SetConfigForm
If ComboCamera.Items.IndexOf(id) > -1 Then If ComboCamera.Items.IndexOf(id) > -1 Then
riga.Cells(3).Value = GetCurrIco(2) riga.Cells(3).Value = GetCurrIco(2)
riga.Cells(2).Value = id riga.Cells(2).Value = id
' aggiungo all'elenco degli id camera
ComboCamera.Items.Add(id)
Else Else
riga.Cells(3).Value = GetCurrIco(0) riga.Cells(3).Value = GetCurrIco(0)
End If End If
@@ -135,21 +137,60 @@ Public Class SetConfigForm
End Try End Try
End Sub End Sub
Private Sub DataGridView1_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
' Controlla se la cella corrente è nella colonna della ComboBox e se il controllo è una ComboBox
If DataGridView1.CurrentCell.ColumnIndex = DataGridView1.Columns("ComboCamera").Index AndAlso TypeOf e.Control Is ComboBox Then
Dim comboBox As ComboBox = TryCast(e.Control, ComboBox)
If comboBox IsNot Nothing Then
' Rimuovi eventuali gestori eventi precedenti per evitare eventi duplicati
' Questo è importante se l'utente modifica più volte la stessa cella
RemoveHandler comboBox.SelectedIndexChanged, AddressOf DataGridViewComboBox_SelectedIndexChanged
' Aggiungi il gestore eventi per l'evento SelectedIndexChanged della ComboBox
AddHandler comboBox.SelectedIndexChanged, AddressOf DataGridViewComboBox_SelectedIndexChanged
End If
End If
End Sub
' Questo è il gestore eventi che si attiverà quando l'utente seleziona un elemento nella ComboBox
Private Sub DataGridViewComboBox_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim comboBox As ComboBox = TryCast(sender, ComboBox)
If comboBox IsNot Nothing Then
Dim selectedValue As String = comboBox.SelectedItem.ToString()
Dim currentRowIndex As Integer = DataGridView1.CurrentCell.RowIndex
Dim IDCamera As String = If(Not IsNothing(DataGridView1.Rows(currentRowIndex).Cells("ComboCamera").Value), DataGridView1.Rows(currentRowIndex).Cells("ComboCamera").Value.ToString(), String.Empty)
If IDCamera <> selectedValue Then
DataGridView1.Rows(currentRowIndex).Cells(4).Value = "Save*"
End If
End If
End Sub
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
' Controlla che il click non sia sull'intestazione della colonna ' Controlla che il click non sia sull'intestazione della colonna
If e.RowIndex < 0 Then Return If e.RowIndex < 0 Then Return
Dim IDConfig As String = DataGridView1.Rows(e.RowIndex).Cells("Config").Value.ToString() Dim IDConfig As String = DataGridView1.Rows(e.RowIndex).Cells("Config").Value.ToString()
Dim IDCamera As String = DataGridView1.Rows(e.RowIndex).Cells("ComboCamera").Value.ToString() Dim IDCamera As String = If(Not IsNothing(DataGridView1.Rows(e.RowIndex).Cells("ComboCamera").Value), DataGridView1.Rows(e.RowIndex).Cells("ComboCamera").Value.ToString(), String.Empty)
' Controlla se il click è avvenuto nella colonna dei bottoni (Usa il nome che hai dato alla colonna) ' Controlla se il click è avvenuto nella colonna dei bottoni (Usa il nome che hai dato alla colonna)
If Me.DataGridView1.Columns(e.ColumnIndex).Name = "SaveConfig" Then If Me.DataGridView1.Columns(e.ColumnIndex).Name = "SaveConfig" Then
SaveIDCamera(IDConfig, IDCamera) If Not String.IsNullOrEmpty(IDConfig) And Not String.IsNullOrEmpty(IDCamera) Then
SaveIDCamera(IDConfig, IDCamera)
DataGridView1.Rows(e.RowIndex).Cells(4).Value = "Save"
Else
MessageBox.Show("Non è possibile salvare l'ID di una camera non connessa.", "Avviso", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End If
PopolateDataGrid() PopolateDataGrid()
ElseIf Me.DataGridView1.Columns(e.ColumnIndex).Name = "ApplyConfig" Then ElseIf Me.DataGridView1.Columns(e.ColumnIndex).Name = "ApplyConfig" Then
Dim IndCamera As Integer = FrmMain.ComboBoxCameras.Items.IndexOf(IDCamera) If Not (String.IsNullOrEmpty(IDConfig) And String.IsNullOrEmpty(IDCamera)) Then
FrmMain.ComboBoxCameras.SelectedIndex = IndCamera Dim IndCamera As Integer = FrmMain.ComboBoxCameras.Items.IndexOf(IDCamera)
Dim IndCameraCfg As Integer = FrmMain.ComboBoxCameraCfg.Items.IndexOf(IDConfig) FrmMain.ComboBoxCameras.SelectedIndex = IndCamera
FrmMain.ComboBoxCameraCfg.SelectedIndex = IndCameraCfg Dim IndCameraCfg As Integer = FrmMain.ComboBoxCameraCfg.Items.IndexOf(IDConfig)
FrmMain.ComboBoxCameraCfg.SelectedIndex = IndCameraCfg
End If
End If End If
End Sub End Sub