거의 같은 일을하는 폼 (예 : 레이블, 단추 등)에 많은 컨트롤이있을 때 종종 한 컨트롤을 사용하여 모든 컨트롤을 처리합니다.VB에서 GridView 셀에서 가져온 웹 컨트롤 캐스팅
그러나 이벤트를 던지고 컨트롤의 속성에 액세스하는 컨트롤을 알고 싶으면 "보낸 사람"개체를 올바른 형식으로 캐스팅해야합니다. DataGridView에있는
:
내가 DataGridView에 내가 이것을 시도 의 셀에 버튼의 텍스트를하고 싶지만이 wotking 아니에요 :들 :의
Dim btnGrid As New DataGridViewButtonColumn
btnGrid.HeaderText = "Modifier les lieu"
btnGrid.Text = "Mise a jour"
btnGrid.UseColumnTextForButtonValue = True
DataGridView1.Columns.Add(btnGrid)
Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
If e.ColumnIndex = 0 Then
index = DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(1).Value
Dim btn As Button = CType(sender, DataGridViewButtonColumn)
MsgBox(btn.Text)
End If
End Sub
문제는 무엇입니까? – Alain
@Alain DataGridview의 셀에있는 버튼의 텍스트를 가져오고 싶습니다. –