I have a datagridview
that I populate from a loop. If I do the following:
public Form(Dictionary<String, String> headers)
{
InitializeComponent();
foreach (var key in headers.Keys) {
datagridview1.Columns.Add(key, key);
}
}
I get a header row containing text.
How do I add buttons and text to the header row of datagridview1 instead of just text?
I am using winforms
and .net 4.5
. (I guess I could switch to 4.5.1 if it makes things easier).
As far as I know this is not possible. Here are ways you could get close:
Frozen
property and put the buttons in the first row. May thats helping you
DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
dataGridView1.Columns.Add(btn);
btn.HeaderText = "YourText";
btn.Text = "YourText";
btn.Name = "DGVbutton1";
btn.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.