Click here to Skip to main content
16,020,249 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want the rows on the datagridview to be added automatically and not with a button like I already have, maybe it can operate using a lable instead. this is what i have already but this works only with a button.

What I have tried:

C#
//add new row start 
        private void button4_Click(object sender, EventArgs e)
        {
            pictureBox2.Image = null;
            try
            {
                createAttendanceBindingSource.AddNew();                
                
            }
            catch
            {
                MessageBox.Show("Clear the fields by clicking clear first", "Fields Not Cleared", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Posted
Updated 17-Jan-17 2:31am
v3
Comments
[no name] 16-Jan-17 18:36pm    
Okay.... since you already know how to do this, what is the question exactly?
King_Eke 16-Jan-17 18:41pm    
I'm using a button to do it, I want assistance on how to make it work with a lable instead
King_Eke 16-Jan-17 18:42pm    
so it would be like, there's a lable on the form called "begin" when the form loads then
if (lable.text == "begin")
{
createAttendanceBindingSource.AddNew();
}

but it doesn't work
[no name] 16-Jan-17 19:37pm    
You should get a decent book on C# programming and work through it to learn the fundamentals first. If you knew the fundamentals, you could see immediately that your "attempt" wouldn't even compile. Then, learn how to use the debugger to debug your code. When you do that, finding and fixing bugs become much easier and then you will be able to ask questions without telling us useless information like "doesn't' work".
King_Eke 17-Jan-17 14:08pm    
Useless? my chest :( . OK Sir

Quote:
I want the rows on the datagridview to be added automatically and not with a button like I already have, maybe it can operate using a lable instead. this is what i have already but this works with a button.

You only have to decide when to add a new row, which event and which conditions.
 
Share this answer
 
If you want automatically Added new row then Add


"DataGridView.AllowUserToAddRows = True"
In your Grid view
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900