c# - Add columns (column headers) to a list view programatically -
i have array of strings , want these strings columns(column headers or column names) of list view. no. of strings not known until run time , columns added programmatically. want define how many columns there in list view. suppose string contains strings = {"str1","str2","str3"}. want list view contain 3 columns namely "str1" ,"str2" , "str3". want know list view property or method can add these.
thank you.
i'm not sure if work list view, i've done grid view, setting autogeneratecolumns="true"
:
datatable dt = new datatable("tablename"); foreach(var col in arrayofstrings) dt.columns.add(col); // add rows datatable // of course, set datasource of listview/gridview listview.datasource = dt; listview.databind();
Comments
Post a Comment