Datareader counter for showing progress/cancel reading the data
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;
}
}
}