c# - DataGridView column auto adjust width and resizable -


i wondering if possible have datgridview column adjust automatically width content , @ same time being resizable user ?

here have tried far :

datagridview.allowusertoresizecolumns = true; datagridview.columns[0].autosizemode=datagridviewautosizecolumnmode.displayedcells; datagridview.columns[0].resizable = datagridviewtristate.true; 

but still unable resize column size manually.

if faced issue or have idea let me know.

thanks.

i find way wanted.

the idea to

  • let datagridview resize columns fit content, , then
  • change theautosizecolumnmode , set width value stored.

here code:

datagridview.columns[i].autosizemode = datagridviewautosizecolumnmode.displayedcells; int widthcol = datagridview.columns[i].width; datagridview.columns[i].autosizemode = datagridviewautosizecolumnmode.none; datagridview.columns[i].width = widthcol; 

hope help.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -