danke02
2017-03-23T05:46:52Z
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)
        {
            
        }
    }
Igor/10Tec
2017-03-23T08:07:41Z
If you open the help topic dedicated to the StaySorted property, you can read this:

引用:

When iGrid is in stay-sorted mode, it changes a row's index when the Value, ImageIndex, BackColor or other property of a cell is changed and the column the cell belongs to is sorted by the changed property. Also when you add a new row, its location is determined according to the current sort criteria and its cells' properties even if you specify the row's index explicitly.



We agree that we should have implemented BeginTransaction/EndTransaction row methods for cases like this, but it would complicate programming. It's obvious enough that a row changes its position if you change its cell belonging to a column iGrid is sorted by, so we decided to go the way we go now and warn about possible "side effects".

The original purpose of the "stay sorted" mode is to simplify the developer's work for the scenario when the user wants to keep the grid in actual sorted state after changing cells from the columns iGrid is sorted by.