Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem that i can't refresh my datagridveiw control
C#
private void button1_Click(object sender, EventArgs e)
        {

            List<Customer> CustList = new List<Customer>();
            CustList.Add(new Customer() { Cust_id = int.Parse(textBox1.Text), Interarrival = int.Parse(textBox2.Text), ServiceTime = int.Parse(textBox3.Text) });
            dataGridView2.DataSource = CustList;

            dataGridView2.Refresh();
        }


for the first time i clicked button1 datagridview filled with data
for the second time nothing occurred
thanks
Posted
Comments
[no name] 17-Oct-12 20:09pm    
I am pretty sure that you would need to set the datasource to null then refresh the datasource.
SquidSK 17-Oct-12 21:49pm    
Given you're newing up your list every time you click the button you should only ever have one thing in your datagrid. What is the behaviour you're talking about when you say "nothing occurred" as that isn't very specific.

1 solution

finally you should add the databind of gridview,then automatically refreshed.
C#
dataGridView2.DataBind();
 
Share this answer
 
v2

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