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:
定义按钮的属性时需要执行此操作。
btnDelete.UseColumnTextForButtonValue = true;
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.