arun sasi
arun sasi

Reputation: 13

Adjusting DatagridviewbuttonColumn width and color

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.

Sample

 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

Answers (1)

SpiderKing88
SpiderKing88

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

Related Questions