Home Forums WinForms controls Xceed Grid for WinForms Virtual Mode and AddingDataRow

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16308 |

        All the examples show using the AddingDataRow event to custom colorize row colors; however the minute you attempt to access a cell in the row it actually loads the row of data.  We have a paging table system that only loads the page when it needs it; so that we aren’t bringing in 100,000 rows of data when the person only wants to see a couple pages of it…  So, I seem to be in a catch 22; I can colorize the rows if I bring in all the data (5 minutes later it might be done) — or I can have a ultra fast pagable grid with no coloring..

       Is their some set of events so that when a row is visible I can check and then colorize it?   Any ideas?

     Nathan

     

     

    Imported from legacy forums. Posted by Nathanael (had 1342 views)

    User (Old forums)
    Member
    Post count: 23064

    I am a total newb with the grid, but maybe you can use the stylesheet stuff to do this?  I have alternating colors and that’s how I’m accomplishing it there.  Maybe there’s something more advanced with that or a DataRowTemplate.

    Imported from legacy forums. Posted by Willie (had 563 views)

    User (Old forums)
    Member
    Post count: 23064

    Exactly, a StyleSheet should do the job.  Here is more information from the help documentation on how to use a StyleSheet.

    If this is not what you are looking for, you could also use the Paint event on the DataRowTemplate, and use the event handler to change the color of the row.

    e.g.:

    private void Form1_Load( object sender, EventArgs e )

    {

        dataRowTemplate1.Paint += new GridPaintEventHandler( dataRowTemplate1_Paint );

    }

    void dataRowTemplate1_Paint( object sender, GridPaintEventArgs e )

    {

        Xceed.Grid.DataRow row = sender as Xceed.Grid.DataRow;

        if( row != null )

        {

            ReadOnlyDataRowList rowList = gridControl1.GetSortedDataRows( true );

            if( row.Index > 0 )

            {

                if( rowList[ row.Index – 1 ].BackColor == Color.Aqua )

                    row.BackColor = Color.Beige;

                else

                row.BackColor =

    Color.Aqua;

            }

            else

                row.BackColor =

    Color.Aqua;

        }

    }

     

    Imported from legacy forums. Posted by André (had 534 views)

    User (Old forums)
    Member
    Post count: 23064

    Actually the paint event is exactly what I was looking for.  I’m not sure why I missed it the first time…   The stylesheets would not work because I color based on a value in one of the cells.

     Nathan

    Imported from legacy forums. Posted by Nathanael (had 507 views)

    User (Old forums)
    Member
    Post count: 23064

    Well, in that case, you can also use the ValueChanged event on the Cell class, and change the BackgroundColor in the event handler accordingly to the value of the cell.

    e.g.:

    private void Form1_Load( object sender, EventArgs e )

    {

        dataRowTemplate1.Cells[

    “ShipperID” ].ValueChanged += new EventHandler( Form1_ValueChanged );

    }

    void Form1_ValueChanged( object sender, EventArgs e )

    {

        Cell cell = sender as Cell;

        if( cell != null )

        {

            if( ( int )cell.Value == 2 )

            {

                cell.ParentRow.BackColor =

    Color.PeachPuff;

            }

        }

    }

     

    Imported from legacy forums. Posted by André (had 244 views)

    User (Old forums)
    Member
    Post count: 23064

       Interesting, that mostly works. Its an interesting solution.  (Probably would be better than the paint event in most cases).

          However, their appears to be a bug in the Xceed grid somewhere — something is apparently causing the ValueChanged event to fire on the wrong row while scrolling.  It keeps wanting to like fire on 1 or 2 rows from the _end_ of the table.   So, my paging table loads page 1, then page 689, then page 1, 689, 1 ….  Then as I scroll it loads page 2, then page 689, then page 2, then 689, then page 2….  Causes some really bad performance…   The grid is virtual since I have something like 34440 records.  Each Page loaded in batches of 50. 

        If I’m tied to the OnPaint request I only see Page 1/2/3/4 in sequence (as expected); but if I tie onto the ValueChanged event, I see that last page trying to be loaded almost like it was trying to show that last row on every scroll down request.

     btw, my event is exactly like yours; it is

       if (cell.value > 0) { cell.ParentRow.Font = new Font(cell.ParentRow.Font, font.strikethrough) }

    rather than the color.   

     

    Nathan.

     

     

     

    Imported from legacy forums. Posted by Nathanael (had 536 views)

    User (Old forums)
    Member
    Post count: 23064

    Interesting indeed…

    It is difficult to tell what could be the problem without actually reproducing the issue.  And for that, we would need to know how you implement your paging, and so on.

    If you want us to get to the bottom of this, you can send us an email, and provide us with a sample application reproducing the issue, or a simple series of steps to reproduce it.  Note however, that you need to have a valid support subscription to be entitled to receive this kind of support.

     

    Imported from legacy forums. Posted by André (had 380 views)

    User (Old forums)
    Member
    Post count: 23064

    I’ve sent in an example to support showing this problem and another minor problem w/ the paint event method.  Hopefully these will be fixed by the Sept release.

     Nathan.

    Imported from legacy forums. Posted by Nathanael (had 447 views)

    User (Old forums)
    Member
    Post count: 23064

    For others who might be interested the issue if you use a virtual grid w/ a paging table and you don’t want the grid to page to the last page and then back, is that the grid reads the final page of data by default to figure out where the thumbnail is at.  

          If you set your site of the DataRowTemplate.Height to your default height, then the grid doesn’t have to look at the last grids.  So on my “browse” grids, I just added the code of line: 

    <gridname>.DataRowTemplate.Height = <gridname>.DataRowTemplate.Height;

     This basically causes the grid to be hard coded to x(16 in my case) number of pixels height for each line.    I assume this removes the ability to wrap lines, unless I manually wrap them — but I don’t need that on my 10000+ row browses.

    Nathan.

    Imported from legacy forums. Posted by Nathanael (had 1621 views)

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.