We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Unable to set Text-Property for columns with index greater than 10 (virtual grid)

Hey,

i have a little problem with your grid control.
I found this thread (http://www.syncfusion.com/forums/88374/how-to-set-gridcontrol-column-header) and in the last rows you wirte the following snippet:

GridB[0,1].Text="Header1"; // Set the Header text for First header cell
GridB[0,2].Text="Header2";


So i tried this solution and after 5 hours i'm getting headache...
I cannot set the text/value of a header column, if it's index is greater than 10!
I have simplified my test code for you. Please check the comments.

private void SetupHeaderTest()
        {
            //works
            gridControl1[0, 3].Text = "Jul";
           

            //works anyways..
            var blu = gridControl1[0, 8];
            gridControl1[0, 8].Text = "Aug";
            var blu2 = gridControl1[0, 8];

            if (blu.Equals(gridControl1[0, 8]))
            {
                //they are not equals
            }

            if (blu.Equals(blu2))
            {
                //they are not equals
            }

           
            //works...
            var test2 = "Sep";
            var bla = gridControl1[0, 10];
            bla.Text = test2;

            //gridControl1[0, 10] = bla; //works!



            //DO NOT work!
            var test3 = "Sep";
            var bla3 = gridControl1[0, 11]; // if column greater then 10, it do not work!
            bla3.Text = test3;

            //gridControl1[0, 11] = bla3; -->arrayOutOfBounds
        }


Can anyone help me out?

best regards
Marcel Elz

1 Reply

SA Solai A L Syncfusion Team July 27, 2015 10:04 AM UTC

Hi Marcel,

Thank you for your interest in Syncfusion products.

We have analyzed your reported scenario. We would like to let you know that by default virtual grid will contain 5 rows and 10 columns bind initially. Only those cells can be accessed by you initially. If you want to access beyond that you need to use QueryCellInfo event. Using events to access is the appropriate way, else the purpose of using Virtual Grid would be waste. Please refer the below code, sample and KB for clarification.

Code Snippet[c#]:          

void GridQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

  {

     //Correct usage. Cell values should be accessed only in events for virtual grid.

      if (e.RowIndex == 0 && e.ColIndex == 11)

         {

           var test3 = "Sep";

           var bla3 = e.Style;

           bla3.Text = test3;

           e.Style.Text = bla3.Text;

          }

   }


KB:

https://www.syncfusion.com/kb/427/what-is-a-virtual-grid


Sample :
http://www.syncfusion.com/downloads/support/forum/119722/ze/CS-685379556

Please let us know if you have any other concerns.

Thanks & Regards,
AL.Solai.


Loader.
Live Chat Icon For mobile
Up arrow icon