"how to change column width in datagridview?" Code Answer

2

you could set the width of the abbrev column to a fixed pixel width, then set the width of the description column to the width of the datagridview, minus the sum of the widths of the other columns and some extra margin (if you want to prevent a horizontal scrollbar from appearing on the datagridview):

datagridview1.columns[1].width = 108;  // or whatever width works well for abbrev
datagridview1.columns[2].width = 
    datagridview1.width 
    - datagridview1.columns[0].width 
    - datagridview1.columns[1].width 
    - 72;  // this is an extra "margin" number of pixels

if you wanted the description column to always take up the "remainder" of the width of the datagridview, you could put something like the above code in a resize event handler of the datagridview.

By Jeff Ayer on February 6 2022

Answers related to “how to change column width in datagridview?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.