Reputation: 13
I have a datagridview Which displays data from database. I am adding a datagridviewbutton column at the end of the datagridview data programatically. I am making this button column as a delete button column. I have added a screenshot of my column. Here i cant decrease the width of the column. And also i want to change the color of the button to red.
DataGridViewButtonColumn Delete = new DataGridViewButtonColumn();
Delete.Width = 2;
Delete.HeaderText = "Delete";
Delete.Text = "Delete";
Delete.UseColumnTextForButtonValue = true;
dgv_listManufact.Columns.Insert(7, Delete);
here the delete.width not working. The width remains same. How to decrease the width? and the color too?
Upvotes: 0
Views: 1375
Reputation: 547
To change the color of the button use:
Delete.Style.BackColor = Color.Red;
Remember to change the autosize
property of the column to false, this will allow you to change the width
Upvotes: 1