Articles in this section
Category / Section

How to copy the content in the header cells of GridControl?

1 min read

In GridControl, to copy the contents of header cell like normal cell, we need to set the HeaderRows and HeaderColumns as zero. Users can have the header like behavior by setting the FrozenRows and FrozenColumns count and set the CellType as Static for that Frozen cells like the below code example

In MainWindow.xaml.cs file,

C#

grid.Model.HeaderColumns = 0;
grid.Model.HeaderRows = 0;
grid.Model.FrozenRows = 1;
grid.Model.FrozenColumns = 1;
grid.Model.Options.CopyPasteOption = CopyPaste.CopyText | CopyPaste.PasteText;
grid.QueryCellInfo += new GridQueryCellInfoEventHandler(grid_QueryCellInfo);
void grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
   if (e.Style.ColumnIndex == 0 || e.Style.RowIndex == 0)
     {
         e.Style.CellType = "Static";
         if (e.Style.RowIndex == 0)
             e.Style.CellValue = e.Style.ColumnIndex;
        else
             e.Style.CellValue = e.Style.RowIndex;
     }
}
 


Please find the sample for your reference,

WPF

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied