I'm adding a button column to my databound datagridview. The column gets created, and the button is clickable, but it doesn't really show. Its kinda hard to explain so I'm posting a screenshot below.
Here's the code
private void LoadDataGridView()
{
dgvClients.DataSource = null;
dgvClients.DataSource = Clients;
DataGridViewButtonColumn btnDelete = new DataGridViewButtonColumn();
btnDelete.Name = "btnDelete";
btnDelete.Text = "Delete";
btnDelete.HeaderText = "Delete";
dgvClients.Columns.Add(btnDelete);
//set column sizes. Total width of dgv w/o scrollbar is 544
dgvClients.Columns[0].Width = 100;
dgvClients.Columns[1].Width = 344;
dgvClients.Columns[2].Width = 100;
dgvClients.Columns[3].Width = 100;
dgvClients.Show();
dgvClients.ClearSelection();
}
Screenshot:
You need to do this when you define the button's properties.
btnDelete.UseColumnTextForButtonValue = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With