c# - DataGridView: Add Data Programatically on Specific Cells -
i'm trying add data programatically onto datagridview, doesn't seem working. have array, fill text file:
public static string pathlist = @"c:\users\gbbb\desktop\pfade.txt"; _pathrows = system.io.file.readalllines(@pathlist);
and have datagridview 4 columns on add many rows have paths, so:
public void initpathstable() { tabellebib.rows.add(_pathrows.length); //and here want add paths on column nr.4 }
next need way add paths (24) column nr.4, 1 path per row. seems impossible beginner me, asking you.
this method you. read comments (especially make sure have added 4 columns datagridview
):
public void initpathstable() { int rowindex; datagridviewrow row; foreach (var line in _pathrows) { rowindex = tabellebib.rows.add(); //retrieve row index of newly added row row = tabellebib.rows[rowindex]; //reference new row row.cells[3].value = line; //set value of 4th column line. warning: tabellebib has have 4 columns added either code or designer othwerwise here exception } }
if more problems, write comment , come :)
Comments
Post a Comment