To help you better we need some information from you.
*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***
Product, version and build:5.8.187
Operating system: Windows 10
PowerShell version(s): 5.1.14393.2828
*** Please add details and screenshots as needed below. ***
Hey all, im new to using datagridview and datatables. I have a datagridview with a datatable as its source, when I add my first entry to the datatable the datagrid view inserts the line as well as a blank line (thus showing two blank lines as well as the data entered).
Can anyone tell me whats going on or how to remove the additional line? I thought at first that the line was on the datatable but with some troubleshooting the additional line is on the datagridview.
Any help, greatly appreciated.
Additional blank rows in datagridview
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
-
- Posts: 5
- Last visit: Thu Aug 24, 2023 9:25 am
-
- Posts: 5
- Last visit: Thu Aug 24, 2023 9:25 am
Re: Additional blank rows in datagridview
I may have solved this or at least worked around the issue. I was assigning the datatable as the source for the datagridview before the datatable had any entries and just headers, adding a row and then assigning as the source for the datagrid view seems to have solved my issue (or, again, provided a work around).
Re: Additional blank rows in datagridview
When creating a DataTable you must use either auto-columns or fixed columns assigned to match the table field names in the properties designer of the column as the data member name. Any other approach will give you odd results. YOU cannot both add columns and assign a table or there will be no way to match the fields.
A table can be assigned and empty and it will either bind to the specified columns or generrate the columns according to the field names. You can then add rows to teh table as needed and they will display in the grid.
If the grid allows adding new rows directly then it will always have an extra blank row for adding data. To not have the blank row just uncheck the property that allows adding a new row.
A table can be assigned and empty and it will either bind to the specified columns or generrate the columns according to the field names. You can then add rows to teh table as needed and they will display in the grid.
If the grid allows adding new rows directly then it will always have an extra blank row for adding data. To not have the blank row just uncheck the property that allows adding a new row.