Hello.
I tried to add new row and modified some cells' values.
Cells of newly added row occasionally had no value which had null value.
I wasted few hours and finally found a condition.
When StaySorted is true and add new row and modify some cell which is a key for sorting,
instance of new row became an instance of other rows(it might be natural with StaySorted = true). So changing columns' value of this row doesn't mean changing values of new row.
Although it is logically right, users would be very confused.
(I'm not sure if this is warned in manual or not. But I could't find anything when I read a manual briefly)
Anyway I could avoid this problem by setting StaySorted as false before adding new row.
Hope to get better answer.
Below is a sample app.
Problem occurs when iGrid1.StaySorted = true and sorting is applied on C1 column.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Timer t = new Timer();
t.Tick += T_Tick;
t.Interval = 1;
t.Start();
}
private void T_Tick(object sender, EventArgs e)
{
Task t = new Task(() =>
{
this.Invoke(new Action(input));
});
t.Start();
}
private void input()
{
iGrid1.StaySorted = false;
iGRow row = iGrid1.Rows.Add();
row.Cells["C1"].Value = data1;
row.Cells["C2"].Value = data2;
data1++;
data2--;
iGrid1.StaySorted = true;
}
int data1 = 0,data2 = 0;
private void button1_Click(object sender, EventArgs e)
{
}
}
Edited by moderator
2017-03-27T06:53:14Z
|
Reason: Igor/10Tec added code formatting, changed post status to 'informative'