• North American Sales: 1-800-231-8588
  • Global Contacts
  • My Account
Infragistics Infragistics
Menu
  • North American Sales: 1-800-321-8588
  • My Account
    • Sign In/Register
  • Design & DevelopmentDesign & Develop
    • Best Value
      Infragistics Ultimate The complete toolkit for building high performing web, mobile and desktop apps.
      Indigo.Design Use a unified platform for visual design, UX prototyping, code generation and application development.
    • Web
      Ignite UI for Angular Ignite UI for JavaScript Ignite UI for React Ultimate UI for ASP.NET Indigo.Design
    • Desktop
      Ultimate UI for Windows Forms Ultimate UI for WPF
      Prototyping
      Indigo.Design
    • Mobile
      Ultimate UI for Xamarin Ultimate UI for iOS Ultimate UI for Android
    • Automated Testing Tools
      Test Automation for Micro Focus UFT: Windows Forms Test Automation for Micro Focus UFT: WPF Test Automation for IBM RFT: Windows Forms
  • UX
    • Indigo.Design Desktop Collaborative prototyping and remote usability testing for UX & usability professionals
    • Indigo.Design A Unified Platform for Visual Design, UX Prototyping, Code Generation, and App Development
  • Business Intelligence
    • Reveal Embedded Accelerate your time to market with powerful, beautiful dashboards into your apps
    • Reveal App Empower everyone in your organization to use data to make smarter business decisions
  • Team Productivity
  • Learn & Support Support
    • Help & Support Documents
    • Blogs
    • Forums
    • Product Ideas
    • Reference Applications
    • Customer Stories
    • Webinars
    • eBook & Whitepapers
    • Events
  • Free Trials
  • Pricing
    • Product Pricing / Buy Online
    • Renew Existing License
    • Contact Us
Windows Forms
  • Product Platforms
  • More
Windows Forms
Windows Forms Select All Rows in WinGrid Programatically
  • Blog
  • Files
  • Wiki
  • Members
  • Mentions
  • Tags
  • More
  • Cancel
  • New
Windows Forms requires membership for participation - click to join
  • Windows Forms
  • Best Practices for Placing a DropDown or Combo in an WinGrid Cell
  • Change Color of Column Headers in WinGrid
  • Disable WinGrid Row, Cell or Column with Activation Object
  • Performance in the WinTilePanel
  • Select All Rows in WinGrid Programatically
  • UI Thread Marshaling in the Model Layer
  • Using an WinGrid DataFilter to Convert Strings to Bools (and vice-versa) for a Checkbox Column

Select All Rows in WinGrid Programatically

To select all the rows in the UltraWinGrid programmatically, the obvious solution is to loop through all the rows and set the Selected Property of each row to true. However, this is inefficient and if there are a lot of rows in the grid, it can take more time than necessary.

A more efficient way to select all of the rows is to use the AddRange method.

C#

this.ultraGrid1.Selected.Rows.AddRange((UltraGridRow[])this.ultraGrid1.Rows.All);

VB

Me.UltraGrid1.Selected.Rows.AddRange(CType(Me.UltraGrid1.Rows.All, UltraGridRow()))

The method listed above will select all of the root-level rows in the grid. This includes rows that are hidden or filtered out. It also means that if the root level is grouped, the GroupBy rows will be selected instead of the data rows.

If you want to select only data rows, you can use the following:

C#

this.ultraGrid1.Selected.Rows.AddRange( this.ultraGrid1.Rows.GetAllNonGroupByRows() );

VB

Me.UltraGrid1.Selected.Rows.AddRange( Me.UltraGrid1.Rows.GetAllNonGroupByRows() )

If you want to select only data rows that are not filtered out, use this code:

C#

this.ultraGrid1.Selected.Rows.AddRange( this.ultraGrid1.Rows.GetFilteredInNonGroupByRows() );

VB

Me.UltraGrid1.Selected.Rows.AddRange( Me.UltraGrid1.Rows.GetFilteredInNonGroupByRows() )

Note: UltraWinGrid does not allow selection across bands. The code listed here demonstrates selecting the rows in the root band only. You cannot select rows from different bands at the same time.

  • WinGrid
  • Share
  • History
  • More
  • Cancel
Related
Recommended