Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8485795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:44:56+00:00 2026-06-10T20:44:56+00:00

reportGrid = new DataGridView(); foreach (DataGridViewColumn col in grid.Columns) { DataGridViewColumn newCol = new

  • 0
reportGrid = new DataGridView();
foreach (DataGridViewColumn col in grid.Columns)
{
    DataGridViewColumn newCol = new DataGridViewColumn();
    newCol = (DataGridViewColumn)col.Clone();
    reportGrid.Columns.Add(newCol);
}

I’m trying to mimic some existing code above that works for a DatagridView but for a UltraGrid but not sure how to Clone the column, I looked at CopyFrom as well which works for UltraGridRows.

 foreach (UltraGridColumn col in grid.DisplayLayout.Bands[0].Columns)
 {
      UltraGridColumn newCol = new UltraGridColumn();  //Errror here as well
      //newCol = (UltraGridColumn)col.Clone();
      newCol.CopyFrom(col);

      reportGrid.DisplayLayout.Bands[0].Columns.Add(newCol);
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:44:57+00:00Added an answer on June 10, 2026 at 8:44 pm

    To refactor the InitializeLayout method I mean to extract all the code written for this method (usually formatting columns for display or other one time configuration of the grid) and put everything in a different method directly callable from your code.

    Then, when your user press the button to print the grid, initialize the gridReport with the same datasource, call the same common code and perform the specific hiding for the columns on the second grid.

    This pseudocode assume you have declared two grid (grdMain with the initial data and grdReport to use for printing) also I assume the presence of a ultraGridPrintDocument to start the printing process

    private void gridMain_InitializeLayout(object sender, InitializeLayoutEventArgs e)
    {
        CommonInitializeLayout(gridMain, e);
    }
    
    
    private void CommonInitializeLayout(UltraWinGrid grd, InitializeLayoutEventArgs e)
    {
       UltraGridBand b = e.Layout.Bands[0];
       // Now do the customization of the grid passed in, for example....
       b.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True;
       b.Override.AllowAddNew = AllowAddNew.No;
       b.Override.NullText = "(Not available)";
       b.Columns["CustName"].Header.Caption = "Customer Name";
       ....... etc ....
    }
    
    private void cmdMakeReport_Click(object sender, EventArgs e)
    {
        // This assignment will trigger the InitializeLayout event for the grdReport
        grdReport.DataSource = grdMain.DataSource;
        // Now the two grids have the same columns and the same data 
    
        // Start to hide the columns not desired in printing
        grdReport.DisplayLayout.Bands[0].Columns["CustID"].ExcludeFromColumnChooser =
                                                                 ExcludeFromColumnChooser.True 
        grdReport.DisplayLayout.Bands[0].Columns["CustID"].Hidden = true;
        // .... other columns to hide.....
    
        // Now print the grdReport
        ultraGridPrintDocument.Grid = grdReport;
        ultraGridPrintDocument.Print();
    }
    
    private void gridReport_InitializeLayout(object sender, InitializeLayoutEventArgs e)
    {
        CommonInitializeLayout(griReport, e);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Kendo Grid I have the default Add a new Record button and
I'm trying to get access to salesforce report data using oauth token. Some time
I am trying to find out how to read the value of my WPF
XNamespace xnRD = http://schemas.microsoft.com/SQLServer/reporting/reportdesigner; XNamespace xnNS = http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition; XAttribute xaRD = new XAttribute(XNamespace.Xmlns +
I need to do some reports that aren't strictly a listing-of-entities. More free-form query,
I've a requirement where i need to pass some objects across the pages. So
I've been fiddling with asp.net mvc 3 with the new razor view engine. My
I want my Ext.grid.CheckboxSelectionModel to be loaded with all checkboxes in the SelectionModel checked.
I am new to NHibernate and have found it extremely interesting. I have been
I having issues exporting a GridView to Excel for some reason. I have two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.