c# - Issues with managing DataGridView rows -


a quick introduction source of problem:

i have datagridview that's child of resizable panel, can adjusted user's mouse input. when panel resized, datagridview's size mirrored along it. idea that, instead of columns , rows of grid auto-sizing fit contents of cells or gridspace, number of columns , rows determined size of grid. width , height of rows , columns pre-determined , don't need adjusted. point of let user adjust row , column quantity. best demonstrated short clip of code in action: resizing panel

to accomplish this, check if panel resizing, and, depending if it's shrinking or growing, columns adjusted accordingly. there's magic going on here, looks this:

if(panel_width_is_growing) {     if(margin >= growing_threshold)     {         datagridviewcolumn column = new datagridviewcolumn();         column.name = "run " + (datagridview.columns.count + 1).tostring();         column.headertext = "run " + (datagridview.columns.count + 1).tostring();          datagridview.columns.add(column);     } }  if(!panel_width_is_growing) {     if(margin <= shrinking_threshold)     {         datagridview.columns.removeat(datagridview.columns.count - 1);     } } 

now, issue comes in. exact same thing add , remove rows grid, though adjusted margins , thresholds account row dimension instead of column dimension. difference i'm looking @ height of panel opposed width:

if(panel_height_is_growing) {     if(margin >= row_threshold)     {         datagridviewrow row = new datagridviewrow();         row.headercell.value =  (datagridview.rows.count + 1).tostring();         datagridview.rows.add(row);                   }                 } 

and no rows appear... can't figure out issue. code hitting necessary lines, verified breakpoints , stepping. rowcount property never incremented , no alarms go off, whole thing wrapped in try catch block. there's no binding associated grid or special functions overload default behavior.

the problem typing (a real boneheaded oversight). datagridviewcolumn doesn't have default cell template, trying add rows column failed. using datagridviewtextboxcolumn cleared right up.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -