Current filter:
                                You should refresh the page.
                                Support Center

                                How to get the GridView selected objects


                                To get all selected objects in the GridView, you should iterate via all selected rows, get row handles, and then by using the GetSelectedRows method get the selected row object itself.
                                See Also:
                                Selections Overview

                                • Johny Woller Skovdal 03.17.2014

                                  May I sugges using LINQ to improve readability a bit:
                                  gridView1.GetSelectedRows().Select(rowHandle => gridView1.GetRow(rowHandle)).Cast<MyObject>();

                                  (if you use mix types you bind to in your grid, consider using "OfType" instead of "Cast")

                                You must  log in  or  register  to leave comments
                                Select file
                                • Form1.cs
                                • Program.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2013 vol 1.4 - v2013 vol 2.9
                                • v2008 vol 2.6 - v2012 vol 2.16
                                using System;
                                using System.Collections.Generic;
                                using System.ComponentModel;
                                using System.Data;
                                using System.Drawing;
                                using System.Text;
                                using System.Windows.Forms;
                                namespace WindowsApplication1 {
                                    public partial class Form1 : Form {
                                        public Form1() {
                                            list = new BindingList<MyObject>();
                                            for(int i = 0; i < 10; i++) {
                                                list.Add(new MyObject(i.ToString(),(i+10).ToString()));
                                            bs = new BindingSource();
                                            bs.DataSource = list;
                                            gridControl1.DataSource = bs;
                                        BindingSource bs;
                                        BindingList<MyObject> list;
                                        private void simpleButton1_Click(object sender, EventArgs e) {
                                            for(int i = 0; i < gridView1.SelectedRowsCount; i++) {
                                                int row = (gridView1.GetSelectedRows()[i]);
                                                MyObject obj = gridView1.GetRow(row) as MyObject;
                                                if(obj == null) return;
                                    public class MyObject: INotifyPropertyChanged {
                                        public MyObject(string str1,string str2) {
                                            field1 = str1;
                                            field2 = str2;
                                        private string field1;
                                        public string Field1 {
                                            get { return field1; }
                                            set {
                                                field1 = value;
                                        private string field2;
                                        public string Field2 {
                                            get { return field2; }
                                            set {
                                                field2 = value;
                                        #region INotifyPropertyChanged Members
                                        private void NotifyPropertyChanged(String info) {
                                            if (PropertyChanged != null) {
                                                PropertyChanged(this, new PropertyChangedEventArgs(info));
                                        public event PropertyChangedEventHandler PropertyChanged;

                                To start a chat you should create a support ticket

                                If you need additional product information, write to us at or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners