I looked at the now deleted reply and noticed you seem to want a master detail view. If that is the case see my code sample. Primary keys are shown for demo purposes only.
minimum rows to display in datagridview
Shaifali jain
420
Reputation points
hello ,
is there a way by which i can set that there must be minimum number of rows is available to display in datagridview regardless of the data it has or not .
Developer technologies Windows Forms
1,931 questions
Developer technologies C#
11,567 questions
Accepted answer
-
Karen Payne MVP 35,586 Reputation points Volunteer Moderator
2023-09-21T13:23:49.37+00:00
1 additional answer
Sort by: Most helpful
-
Karen Payne MVP 35,586 Reputation points Volunteer Moderator
2023-09-20T17:11:06.8833333+00:00 If the DataGridView.DataSource is not set.
if (dataGridView1.RowCount < 4) { dataGridView1.RowCount = 4; }
Else if the DataSource is set than you need to decide what to do for instance if the DataSource is a DataTable, check the row count and dependent on rules for DataColumns decide how to add rows to the DataTable etc.