winforms - C#: Datagridview not displaying the data -
i working on winforms application. on form drag , drop datagridview control , set of properties using properties window. following code using populate datagridview. wrote code inside constructor.
list<mycustomclass> lst = new list<mycustomclass>(); lst = loadlist(/*some params here*/);//now uptil point works i.e list contains values desribed. datagridview1.datasource = lst;
the problem when run program nothing displayed in datagridview.
for more details following code represents properties set using properties window
this.datagridview1.allowusertoaddrows = false; this.datagridview1.allowusertodeleterows = false; this.datagridview1.allowusertoresizerows = false; this.datagridview1.anchor = ((system.windows.forms.anchorstyles)(((system.windows.forms.anchorstyles.top | system.windows.forms.anchorstyles.left) | system.windows.forms.anchorstyles.right))); this.datagridview1.autosizecolumnsmode = system.windows.forms.datagridviewautosizecolumnsmode.fill; this.datagridview1.backgroundcolor = system.drawing.color.white; this.datagridview1.columnheadersheightsizemode = system.windows.forms.datagridviewcolumnheadersheightsizemode.autosize; this.datagridview1.gridcolor = system.drawing.color.white; this.datagridview1.location = new system.drawing.point(2, 329); this.datagridview1.margin = new system.windows.forms.padding(2); this.datagridview1.multiselect = false; this.datagridview1.name = "datagridview1"; this.datagridview1.rowheadersvisible = false; this.datagridview1.selectionmode = system.windows.forms.datagridviewselectionmode.fullrowselect; this.datagridview1.size = new system.drawing.size(334, 106); this.datagridview1.tabindex = 0;
add code before assigning datasource , should fine
datagridview1.autogeneratecolumns = true;
edit
also check if have public properties used display contents of class columns in datagridview
Comments
Post a Comment