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
datagridviewresize columns fit content, , then - change the
autosizecolumnmode, 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
Post a Comment