A
Amadej
Hello everyone,
I'm doing some tests with SQL CE and decided to use the ListView
control to display data. The problem is the control hangs (freezes)
the whole application if I, for instance, use the slidebar on it to
scroll down a bit.
Just to make sure this only happens with the ListView control, I
created a button and clicked it numerous times, while the list was
filling, and the application continued to respond fine.
The device doesn't seem to be overutilised either, as I can
smart-close the application fine (and start others) even after the
ListView control makes the application stop responding.
Could it be the fact that I have 40.000 records in my SQL database I
am filling into the ListView control?
Here's the code I'm using:
....
ListViewItem lvi;
System.Threading.Thread FillThread;
....
private void button2_Click(object sender, System.EventArgs e)
{
FillThread = new System.Threading.Thread(new
System.Threading.ThreadStart(FillThreadImpl));
FillThread.Start();
}
....
private void FillThreadImpl()
{
try
{
SqlCeCommand oCmd = conn.CreateCommand();
oCmd.CommandText = "SELECT RTRIM(ProductName),RTRIM(ListPrice)
FROM Produkti";
SqlCeDataReader oReader = oCmd.ExecuteReader();
while (oReader.Read())
{
lvi = new ListViewItem(oReader.GetString(0));
lvi.SubItems.Add (oReader.GetString(1));
listView1.Items.Add(lvi);
}
MessageBox.Show("Done");
}
catch (SqlCeException ex)
{
MessageBox.Show("SQL+ " + ex.Message);
}
catch (System.Exception ex)
{
MessageBox.Show("SYS: " + ex.Message);
}
}
Any ideas what could be wrong?
Thanks in advance,
Amadej.
I'm doing some tests with SQL CE and decided to use the ListView
control to display data. The problem is the control hangs (freezes)
the whole application if I, for instance, use the slidebar on it to
scroll down a bit.
Just to make sure this only happens with the ListView control, I
created a button and clicked it numerous times, while the list was
filling, and the application continued to respond fine.
The device doesn't seem to be overutilised either, as I can
smart-close the application fine (and start others) even after the
ListView control makes the application stop responding.
Could it be the fact that I have 40.000 records in my SQL database I
am filling into the ListView control?
Here's the code I'm using:
....
ListViewItem lvi;
System.Threading.Thread FillThread;
....
private void button2_Click(object sender, System.EventArgs e)
{
FillThread = new System.Threading.Thread(new
System.Threading.ThreadStart(FillThreadImpl));
FillThread.Start();
}
....
private void FillThreadImpl()
{
try
{
SqlCeCommand oCmd = conn.CreateCommand();
oCmd.CommandText = "SELECT RTRIM(ProductName),RTRIM(ListPrice)
FROM Produkti";
SqlCeDataReader oReader = oCmd.ExecuteReader();
while (oReader.Read())
{
lvi = new ListViewItem(oReader.GetString(0));
lvi.SubItems.Add (oReader.GetString(1));
listView1.Items.Add(lvi);
}
MessageBox.Show("Done");
}
catch (SqlCeException ex)
{
MessageBox.Show("SQL+ " + ex.Message);
}
catch (System.Exception ex)
{
MessageBox.Show("SYS: " + ex.Message);
}
}
Any ideas what could be wrong?
Thanks in advance,
Amadej.