I am trying to fetch data from DB and loading the DB with the values fetched. Later I am sorting the Data in the Table based on Name, then I want to bind it with a CheckedListBox
However, when I am trying to use the DataView class as shown in the code below, I see a flickering occuring while the displaying data and once all data is sorted, then it becomes stable.
How to get rid of the flickering? In the sense, I want to SORT all the data and display all of them at once.??
myReader = cmd.ExecuteReader();
while (myReader.Read())
{
myTableForCBL.Rows.Add(myReader["Name"],myReader["rollNumber"]);
}
DataView view = myTableForCBL.DefaultView;
view.Sort = "Name";
checkedListBox1.DataSource = myTableForCBL; //datatable for checked list box
checkedListBox1.DisplayMember = "Name";
checkedListBox1.ValueMember = "rollNumber";
This is because I am sorting the way the data is shown and not merely the data itself. So, it flickers. Rather than that, sort the Data in the DataTable using the
DataRow[] rows = DataTable.select(filterexpression, sortVariable);
//make sure the filterexpression=””, to select all rows else if you want certain rows, write a filterexpression that does the filtering.
//sortVariable to be a column of the DataTable
then import the rows to another temp table and source that to the CheckedListBox
Then the flickering or flashing of the Data Stops.