How to get selected automatically on grid? I created timer but timer doesn't save grid selection. For example when I select grid's 3rd index then 5 second later it select 1st grid index. So I need other solution here.
private void formList_Load(object sender, EventArgs e)
{
BindingSource bs = new BindingSource();
DataTable _dt =_myFunction.Select_New_Inserted_Info(_lDataParameter).Tables[0];
bs.DataSource = _dt;
gridControl1.DataSource = bs;
timer1.Interval = 5000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
BindingSource bs = new BindingSource();
DataTable _dt =_myFunction.Select_New_Inserted_Info(_lDataParameter).Tables[0];
bs.DataSource = _dt;
gridControl1.DataSource = bs;
}
bs.Current;
System.Windows.Forms.Timer
's ' Tick
' event. EDIT
The selection pointer is handled by BindingSource. so, you have to put the BindingSource outside the function Your code will look like this:
BindingSource bs = new BindingSource();
private DataTable GetDataTable()
{
//Please consider checking the populating data function from errors, or post your code to help you with.
DataTable dt =_myFunction.Select_New_Inserted_Info(_lDataParameter).Tables[0];
return dt;
}
private void formList_Load(object sender, EventArgs e)
{
DataTable _dt = GetDataTable();
bs.DataSource = _dt;
gridControl1.DataSource = bs;
timer1.Interval = 5000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
DataTable _dt = GetDataTable();
bs.DataSource = _dt;
gridControl1.DataSource = bs;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.