があります。各行に関連付けられDataGridView
た編集があります。Button
イベントCellContentClick
で、動的にいくつかのtextbox
およびLabel
コントロールを削除および作成していますTableLayoutPanel
この動的な削除とコントロールの作成には、ちらつきにも時間がかかります (これは大きな問題ではありません)。
buttons
しかし、問題は、全体TableLayoutPanel
が完全に混乱した後も、誰かがさまざまな行の編集を継続的にクリックし続ける場合です。
私によると、これは私CellContentClick
のイベントが完了する時間がなく、イベントが完了する前にbutton
他の行の編集をクリックすることで発生しています。そして、私はこの状況に対処することができません
ハンドラー コードは次のとおりです。
Private Sub gdXMLDOc1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles gdXMLDOc1.CellContentClick
Try
If lockThis = False Then
lockThis = True
If e.ColumnIndex = 0 Then
intPreviousRowIndex = intSelectedRowIndex
intSelectedRowIndex = e.RowIndex
gdXMLDOc1.Rows(intSelectedRowIndex).DefaultCellStyle.BackColor = Color.LightSkyBlue
If intPreviousRowIndex <> -1 And intPreviousRowIndex <> intSelectedRowIndex Then
arrQuestion(intPreviousRowIndex).questionText = Replace(txtQText_New.Text, """", "\""")
arrQuestion(intPreviousRowIndex).choice = Replace(txtOpt1_New.Text, """", "\""")
For i As Integer = 0 To arrQuestion(intPreviousRowIndex).cText_eng.Length - 1
arrQuestion(intPreviousRowIndex).cText(i).line = Replace(TableLayoutPanel1.GetControlFromPosition(2, i + 3).Text, """", "\""")
Next
For i = TableLayoutPanel1.RowCount - 1 To 3 Step -1
TableLayoutPanel1.RowCount = TableLayoutPanel1.RowCount - 1
TableLayoutPanel1.Controls.Remove(TableLayoutPanel1.GetControlFromPosition(0, i))
TableLayoutPanel1.Controls.Remove(TableLayoutPanel1.GetControlFromPosition(1, i))
TableLayoutPanel1.Controls.Remove(TableLayoutPanel1.GetControlFromPosition(2, i))
Next
End If
TableLayoutPanel1.RowCount = 4
txtQText.Text = arrQuestion(intSelectedRowIndex).questionText_eng
txtOpt1.Text = arrQuestion(intSelectedRowIndex).choice_eng
txtQText_New.Text = arrQuestion(intSelectedRowIndex).questionText
txtOpt1_New.Text = arrQuestion(intSelectedRowIndex).choice
TableLayoutPanel1.RowCount = TableLayoutPanel1.RowCount - 1
Dim intRowIndex As Integer = TableLayoutPanel1.RowCount
For i As Integer = 0 To arrQuestion(intSelectedRowIndex).cText_eng.Length - 1
Dim lbl As Label = New Label()
lbl.AutoSize = True
lbl.Font = New System.Drawing.Font("Arial", 11.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
lbl.Size = New System.Drawing.Size(73, 36)
lbl.TabIndex = 5
lbl.Text = "Line" + arrQuestion(intSelectedRowIndex).cText_eng(i).lineId.ToString
Dim TxtBox1 As dynamicTextBox = New dynamicTextBox()
TxtBox1.Text = arrQuestion(intSelectedRowIndex).cText_eng(i).line
Dim TxtBox2 As TextBox = New TextBox()
TxtBox2.Font = New System.Drawing.Font("Mangal", 13.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TxtBox2.MaxLength = 50000
TxtBox2.Size = New System.Drawing.Size(600, 37)
TxtBox2.TabIndex = 16
TxtBox2.Text = arrQuestion(intSelectedRowIndex).cText(i).line
TableLayoutPanel1.RowCount = TableLayoutPanel1.RowCount + 1
TableLayoutPanel1.Controls.Add(lbl, 0, intRowIndex)
TableLayoutPanel1.Controls.Add(TxtBox1, 1, intRowIndex)
TableLayoutPanel1.Controls.Add(TxtBox2, 2, intRowIndex)
intRowIndex = TableLayoutPanel1.RowCount
Next
End If
lockThis = False
End If
Catch ex As Exception
End Try
End Sub