This is a migrated thread and some comments may be shown as answers.

Column resize on automatic updated radgridview issue

1 Answer 46 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ziblib
Top achievements
Rank 1
Ziblib asked on 14 Feb 2016, 07:04 AM

Hi,

 I have a form with a radGridView (with 4 columns), the radGridView datasource is a datatable which i update every one second.

When i try to resize any column the width is being reset instead of stretching according to the mouse position.

 

Here is the test application code :

 

Random rndRandom = new Random();

private void RadForm1_Load(object sender, EventArgs e)
{
    radGridView1.AutoGenerateColumns = false;

    timer1.Start();
}



private void timer1_Tick(object sender, EventArgs e)
{
    DataTable dt = new DataTable();
    dt.Columns.Add("AAA1", typeof(int));
    dt.Columns.Add("AAA2", typeof(int));
    dt.Columns.Add("AAA3", typeof(int));
    dt.Columns.Add("AAA4", typeof(int));

    for (int i = 0; i < 20; i++)
    {
        DataRow dr = dt.NewRow();

        dr["AAA1"] = rndRandom.Next();
        dr["AAA2"] = rndRandom.Next();
        dr["AAA3"] = rndRandom.Next();
        dr["AAA4"] = rndRandom.Next();

        dt.Rows.Add(dr);
    }

    radGridView1.DataSource = dt;
}

 

Is there anyway to sort this issue?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Feb 2016, 02:56 PM
Hello ,

Thank you for writing.
 
This scenario can't be considered as valid because when you change the RadGridView.DataSource, the whole grid is refreshed in order to display the new data. If a resize operation is ongoing when the timer ticks, you can encounter an invalid state for the grid. That is why I would recommend you skip the DataSource reset when resize cursor is applied to the grid:
private void timer1_Tick(object sender, EventArgs e)
{
    if (this.radGridView1.Cursor != Cursors.SizeWE)
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("AAA1", typeof(int));
        dt.Columns.Add("AAA2", typeof(int));
        dt.Columns.Add("AAA3", typeof(int));
        dt.Columns.Add("AAA4", typeof(int));
 
        for (int i = 0; i < 20; i++)
        {
            DataRow dr = dt.NewRow();
 
            dr["AAA1"] = rndRandom.Next();
            dr["AAA2"] = rndRandom.Next();
            dr["AAA3"] = rndRandom.Next();
            dr["AAA4"] = rndRandom.Next();
 
            dt.Rows.Add(dr);
        }
 
        radGridView1.DataSource = dt; 
    }
}

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Ziblib
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or