I have a DataGridview called "dgvDynamic" which displays data from a MS Access DB into a DataGridView. I want to show the value of the selected cell, into a textbox called "txtSelectedCell".
However, it will only show data of a string datatype in the textbox, not integers. How can I display both strings and integers in the textbox? Thank you. Here is the code:
Private Sub dgvDynamic_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvDynamic.CellContentClick
txtSelectedCell.Text = dgvDynamic.SelectedCells(0).Value.ToString
End Sub
Turns out I used the wrong event. Instead of using the "CellContent" event I should've used the "ClickEvent" and then changing the statement
From: txtSelectedCell.Text = dgvDynamic.SelectedCells(0).Value.ToString
To: txtSelectedCell.Text = dgvDynamic.CurrentCell.Value.ToString()
Thanks @Codex for solving the problem for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.