c# - DataGridView - Suppress string's cut off -


i'm trying resize datagridviewcell smaller width autosize does.

for example, in 1 column there "a" or nothing possible, if resize column (doesn't matter if manually or programmatically) string "cut off" "a...".

is there way suppress behaviour? want "a" fit between borders of cell in order provide maximum amount of data possible.

edit: make problem clear: autosize leaves litle amount of blank space on every side of column.

you should trim values. have trailing white-spaces after a. here's short demo explains behavior:

datagridview1.datasource = new[] {      new{a="a                "},     new{a="a"},     new{a=""} }; 

after re-sizing, you'll see first row has trailing dots.

alternatively, may try set column's wrap mode, padding, alignment , width:

datagridview1.columns[0].defaultcellstyle.wrapmode = datagridviewtristate.true; datagridview1.columns[0].defaultcellstyle.padding =new padding(0); datagridview1.columns[0].defaultcellstyle.alignment =      datagridviewcontentalignment.middlecenter; datagridview1.columns[0].width = (int)this.font.size * 96 / 72; 

Comments