Kodumu çalıştırdığımda dataGridView TopLeftHeaderCell'in de bir combobox'ı var. Bunu nasıl değiştirebilirim?DataGridView Üstbilgileri'ne Combobox Ekleme
İşte benim kod:
comboBoxHeaderCell.Location = dataGridView.GetCellDisplayRectangle(i, -1, true).Location;
hep 0,0
dönecektir,
public void AddHeaders(DataGridView dataGridView)
{
for (int i = 0; i < 4; i++)
{
// Create a ComboBox which will be host a column's cell
ComboBox comboBoxHeaderCell = new ComboBox();
comboBoxHeaderCell.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxHeaderCell.Visible = true;
foreach (KeyValuePair<string, string> label in _labels)
{
comboBoxHeaderCell.Items.Add(label.Key);
}
// Add the ComboBox to the header cell of the column
dataGridView.Controls.Add(comboBoxHeaderCell);
comboBoxHeaderCell.Location = dataGridView.GetCellDisplayRectangle(i, -1, true).Location;
comboBoxHeaderCell.Size = dataGridView.Columns[0].HeaderCell.Size;
comboBoxHeaderCell.Text = _labels[i].Key;
}
}
size
Kodunuza
Ve çözüm? OP, her bir sütun başlığına her bir combobox'ı eklemek istemektedir, sadece onun kodunun neden çalışmadığını açıklamamaktadır. –
Hiç bir çözümüm yok çünkü hala neden bunu yapacağını bilmiyorum. ne yapmak istediğini açıklarsa, –
yardım edebilirim Her başlık için bir combobox'a ihtiyacım var, topLeftHeaderCell – user2576562