C# dataset clear method -


I'm new to C # I want to create a window with a Knboboks and Detagreed scene. I fill out the DataGrid view based on the value selected from the CONGBOX. So far, so good. But when I change the value of the tell, and like so many attempts to reload the contents of the DataGridView:

  private void comboBox1_SelectedIndexChanged (object sender, EventArgs e) {if (! ComboBox1. SelectedValue = nULL) {If (ds.Tables.Contains ( "League")) {ds.Tables [ "leagues"]. clean (); // and & lt; - error occurs here) league adapter. Select Comand Parameter [0]. Value = combo box. Value selected; Main. Insert Commander Parameter [0]. Value = combo box. Value selected; League adapters. Filled (DS, "League"); }}   

myDataSet.Tables [ "mytable"] Clear () said , I have the following to get a DataGridView Default Error dialog :.

System.IndexOutOfRangeException: Index 0 System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetError (Int32 rowIndex) is not a value on System.Windows.Forms.ConcurrencyManager.get_Item (Int32 index) at . It can handle the DataError event to replace the default dialog.

I also have a fine button.

It only happens when I told you to change the material, for a certain price, for some other value though, if I hit the right button of time, I think with every hit, One row is an element and one column is removed after one, and when I consume all the elements with the fine button, I finally get what I wanted: With the new data in the DataGrade view Please help me, any reply is appreciated. thank you in advanced.

Clear the force and reset it after reloading the data:

  private void comboBox1_SelectedIndexChanged (object sender, EventArgs e) {dataGridView.DataSource = null; // Reload the data with the code in your question     dataGridView.DataSource = // the same code as you are using correctly // Now set the binding to do)

Comments