hi,
I want to show in a seperate form the numbers (counter) of records read from a datareader.
I need this to show the progress and the option to cancel/stop the datareader from reading.
I don't know how to do it to get it works....RecordCounterForm is still empty :-(
// Mainform
..
..
RecordCounterForm rc = new RecordCounterForm();
int RecordCount = 0;
rc.ChildText = "Start met tellen";
rc.Show();
while (reader.Read())
{
RecordCount++;
rc.ChildText = RecordCount.ToString();
// if rc.CancelButton then stop
}
..
..
///childform with the counter
namespace Demo
{
public partial class RecordCounterForm : Form
{
public RecordCounterForm()
{
InitializeComponent();
}
public String ChildText
{
get { return txtChildText.Text; }
set { txtChildText.Text = value; }
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
this.Close();
}
private void UpdateText(string ChildText)
{
txtChildText.Text = ChildText;
}
}
}
Loading
MiekePosted Jan 11, 2011, 9:34 AM
Thanks, I will have a look
Sam HobbsPosted Jan 11, 2011, 12:22 AM
Tim ClaasonPosted Jan 10, 2011, 3:22 PM
Are you really buying yourself anything by allowing cancellation during Reader iteration? You can load a Reader into a DataTable, and use your datatable as a datasource.