We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

If a new DataRow is added to the DataTable during runtime, then how can I trigger the update?

Platform: WinForms |
Control: AutoComplete |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

You need to call this.autoComplete1.SetTableData() method which sets the internal table data based on the AutoComplete control's DataSource property.

C#

DataTable dt;

private void Form1_Load(object sender, System.EventArgs e)

{

dt=new DataTable("select");

dt.Columns.Add("Countries");

dt.Columns.Add("states");

dt.Rows.Add(new object[]{"NorthCarolina" });

dt.Rows.Add(new object[]{"India " });

dt.Rows.Add(new object[]{"New York " });

dt.Rows.Add(new object[]{"Washington " });

dt.Rows.Add(new object[]{"London"});

dt.Rows.Add(new object[]{"Canada"});

autoComplete1.DataSource=dt;

}

private void button1_Click(object sender, System.EventArgs e)

{

dt.Rows.Add(new object[]{"new1"});

dt.Rows.Add(new object[]{"new2"});

//sets the internal table data based on the AutoComplete.DataSource property.

this.autoComplete1.SetTableData ();

}

VB

Private dt As DataTable

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)

dt = New DataTable("select")

dt.Columns.Add("Countries")

dt.Columns.Add("states")

dt.Rows.Add(New Object() {"NorthCarolina"})

dt.Rows.Add(New Object() {"India "})

dt.Rows.Add(New Object() {"New York "})

dt.Rows.Add(New Object() {"Washington "})

dt.Rows.Add(New Object() {"London"})

dt.Rows.Add(New Object() {"Canada"})

autoComplete1.DataSource = dt

End Sub

Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

dt.Rows.Add(New Object() {"new1"})

dt.Rows.Add(New Object() {"new2"})

Me.autoComplete1.SetTableData

End Sub

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon