Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Columns for DevExpress.XtraGrid.GridControl in C#

I try to get the ColumnNames and the current Vieworder of my GridControl. The docu won't help me an the ".Net Reflector"-Tool also won't give me advice.

The tip from an other stackoverflowpost ( How to hide column of devexpress XtraGrid ) also won't help me, because, i can't access View.Columns

like image 886
Kevin Busch Avatar asked Sep 24 '12 10:09

Kevin Busch


1 Answers

I suggest you are trying to use property gridControl.MainView to access a view. This property is of type BaseView (base class for all views) so in order to access columns/order information you should cast it to GridView (or whatever type you are using):

var firstColumnName = ((GridView)gridControl.MainView).Columns[0].FieldName;
like image 71
pakeha_by Avatar answered Sep 21 '22 02:09

pakeha_by