vb.net - Copy a DataGridView -


i'm trying take copy of datagridview.

public sub copydataview(byval ingrid datagridview,                         byval inprinthiddencols boolean)     datagridview1 = ingrid 

i alter configuration of datagridview1 do:

    datagridview1.refresh()     datagridview1.visible = true 

the problem i'm having done datagridview1 , original grid changed , refreshed. despite fact original grid passed byval.

i've tried processing passed grid, column, column, row row, error

"provided column belongs datagridview control" 

the datagridview1 initialized

    cursor.current = cursors.waitcursor     try         datagridview1.columns.clear()         datagridview1.rows.clear()         datagridview1.autosize = true         datagridview1.autogeneratecolumns = false         datagridview1.rowheadersvisible = false              each col datagridviewcolumn in ingrid.columns             if col.width = 0 or _                col.displayed = false , _                not (inprinthiddencols)                 skipcells.add(col.index)             else                 dim c new datagridviewcolumn                 c = col                 datagridview1.columns.add(c)  ' <----------------------                 colwidth_csv.add(modfunctions.getwidthoftext(col.width, f))             end if         next 

on first column added. i've searched instances of error, solutions "copy datasource", there no datasource, generated table. can't find way transform datagridview data datasource either.

what missing? suggestions?

i've ended doing this:

dim c new datagridviewcolumn c = col.clone datagridview1.columns.add(c) 

i seems work fine now.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -