Reputation: 34198
Hello people :) I want to bind my comboboxes to dgv cells . when dgv cells will be resize change size automaticli comboboxes size . and want to dock on above dgv cells how can i make this?
Upvotes: 0
Views: 920
Reputation: 15354
Actually your problem is not cleared much.
Here I am adding another answer. As you have said in one of your reply that you want to resize "yourComboboxColumn" on changing the size of "Products" Column
Put this Code: In the ColumnWidthChange event
if (DGV.Columns.Contains("yourColumn") && e.Column == dataGridView1.Columns["Products"])
{
DGV.Columns["yourColumn"].Width = e.Column.Width;
}
Edited:
To bind data of your combobox
to ComboboxColumn
do this
((DataGridViewComboBoxColumn) DGV.Columns["yourColumn"]).DataSource = cb.Items;
//"yourColumn" is the comboBoxColumn in DGV
// cb is the ComboBox which contains Items
Upvotes: 1
Reputation: 15354
To resize your Columns on Changing the size of DGV set AutoSizeColumnMode to Fill
DGV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
Edited:
In the ColumnWidthChange event of DGV put below code
foreach (DataGridViewColumn column in DGV.Columns) //DGV is your dataGridView
{
column.Width = e.Column.Width;
}
Upvotes: 1