Controls [vb.net] datagridview 에서 endedit 호출 후 DataSource 의 checkbox 적용 안됨
페이지 정보
본문
datagridview 에서 endedit 호출 후 DataSource 의 checkbox 적용 안됨
Public Class Form1
Private WithEvents dt As New DataTable
Private WithEvents dgv As New DataGridView
Private WithEvents cm As New ContextMenuStrip
Private WithEvents Item1 As New ToolStripButton With {.Text = "Item1"}
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Size = New Size(400, 300)
With dt
.Columns.Add(New DataColumn("check1", GetType(Boolean)))
.Columns.Add(New DataColumn("check2", GetType(Boolean)))
.Columns.Add(New DataColumn("text1", GetType(String)))
End With
cm.Items.Add(Item1)
dgv.Size = New Size(375, 250)
dgv.DataSource = dt
dgv.EditMode = DataGridViewEditMode.EditOnEnter
dgv.ContextMenuStrip = cm
Me.Controls.Add(dgv)
End Sub
Private Sub cm_Opening(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles cm.Opening
If dgv.CurrentRow.IsNewRow Then Exit Sub
If dgv.CurrentCell.IsInEditMode Then
dgv.EndEdit()
CType(dgv.CurrentRow.DataBoundItem, DataRowView).EndEdit()
End If
End Sub
Private Sub dt_RowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles dt.RowChanged
'write current values to Immediate Window
Debug.WriteLine(String.Format("check1: {0}, check2: {1}, text1: {2}", e.Row(0).ToString, e.Row(1).ToString, e.Row(2).ToString))
End Sub
End Class
- 이전글[vb.net] UrlEncode 20.04.01
- 다음글[vb.net] 랜덤(Random)문자 생성 20.03.17
댓글목록
등록된 댓글이 없습니다.