This post has been edited by zakary: 22 April 2008 - 08:12 AM
Datagrid RowsHow to set the Max row count
Page 1 of 1
5 Replies - 5567 Views - Last Post: 22 April 2008 - 10:56 AM
#1
Datagrid Rows
Posted 22 April 2008 - 08:11 AM
I am using a Datagrid to add some configuration fields I only want to user to enter a total of 5 rows no more, I have google'd and have not found any info on setting the Max number of rows. Is this possible.
Replies To: Datagrid Rows
#2
Re: Datagrid Rows
Posted 22 April 2008 - 08:16 AM
5 rows per page or you just want to limit the results to 5 rows total?
#3
Re: Datagrid Rows
Posted 22 April 2008 - 08:28 AM
5 rows total the user can add and delete rows but when they can never have any more than 5 rows in the datagrid
#4
Re: Datagrid Rows
Posted 22 April 2008 - 09:31 AM
There isn't a max count property that I know of. You will just have to check the row count each time a user adds a new row and disallow if there is 5 rows already.
Are you using a DataSource to bind to your DataGrid, like a DataSet?
You will need to get the row count from the data source, not the DataGrid.
Are you using a DataSource to bind to your DataGrid, like a DataSet?
You will need to get the row count from the data source, not the DataGrid.
#5
Re: Datagrid Rows
Posted 22 April 2008 - 10:00 AM
Thanks Jayman I figured it out I had to add in my InitializeComponent() method a RowEnter event handle on my dataGridView
then I add the following code and it works the user can only add 5 rows
dataGridView1.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(dataGridView1_RowEnter);
then I add the following code and it works the user can only add 5 rows
void dataGridView1_RowEnter(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
{
if (dataGridView1.RowCount >= 6)
{
dataGridView1.AllowUserToAddRows = false;
}
}
This post has been edited by zakary: 22 April 2008 - 10:01 AM
#6
Re: Datagrid Rows
Posted 22 April 2008 - 10:56 AM
Originally you said you were working with a DataGrid, but I see you are actually using the GridView.
Just an FYI, it is important to state the correct controls that you are using. We will then be able to provide more effective and accurate answers.
I am glad you were able to arrive at a solution.
Just an FYI, it is important to state the correct controls that you are using. We will then be able to provide more effective and accurate answers.
I am glad you were able to arrive at a solution.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|