Copied RSS Feed

Development

GridControl loading data from database in virtual mode

The Syncfusion Windows Forms GridControl is a high performance Grid that is capable of loading data in virtual. In this sample, the Grid pages in data from a SQL Server database when scrolled.

Download sample: WF_GCPagingVirtualDB.zip

 

private void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
        {
            if (e.RowIndex == 0 && e.ColIndex > 0)
            {
                e.Style.Text = retriever.Columns[e.ColIndex - 1].ColumnName;
            }
            else if (e.RowIndex > 0 && e.ColIndex > 0)
            {
                if (this.myData == null || this.myData.RowCount == 0)
                    return;

                if (this.myData.EnsureDataAvailable(e.RowIndex))
                {
                    int rowPos = e.RowIndex - this.gridControl1.Rows.HeaderCount -           this.myData.StartRow - 1;

                    if (rowPos >= this.myData.ActiveTable.Rows.Count)
                        return;
                    int colPos = e.ColIndex - this.gridControl1.Cols.HeaderCount - 1;
                    e.Style.CellValue = this.myData.ActiveTable.Rows[rowPos][colPos];
                    e.Style.BackColor = this.myData.ActiveTableColor;
                }
            }
        }

 

Meet the Author

Davis Jebaraj