C# .NET - devExpress GridView Hide columns

Asked By Shan on 28-Feb-12 03:03 AM
Hi,

 I have devExpress gridview and I have assigned the datasource.
 It loads 5 columns.I want to hide the column 0 and column 5.
 
dipa ahuja replied to Shan on 28-Feb-12 03:04 AM
try this 

grid1.Columns[2].Visible = false ;
Somesh Yadav replied to Shan on 28-Feb-12 03:27 AM

You should use the View.Columns[someFieldName].Visible property to hide / show a column. Please also refer to the following topic:

http://documentation.devexpress.com/#WindowsForms/CustomDocument753

D Company replied to Shan on 28-Feb-12 03:46 AM
Set column visible property false(it will only work if u are not creating the columns dynamically)
or through code do like this
Yourdevgrid.Columns[Index].Visible = false;//put the index value


Hope this helps
Regards
D
kalpana aparnathi replied to Shan on 28-Feb-12 06:12 AM
hi,

Try this steps:

1. You don't need to create a GridView and assign it to the GridLookUpEdit as the View property. When you instantiate a GridLookUpEdit programmatically, it will automatically create a default View. The XtraGrid does the same thing.

2. You don't need to handle an event to set the column's visibility within the ShownEditor event UNLESS you want to decide at runtime to toggle the column's visibility. That is, for one row you may want to show Column A, and in another row you don't. If this isn't the case, you can set the visibility when you create the control.

3. Just set the Column's Caption proeprty for the "Dependent_Desc" field.


 

  //Create a GridLookUpEdit repository item

            DevExpress.XtraEditors.Repository.RepositoryItemGridLookUpEdit gridLookupEdit = new DevExpress.XtraEditors.Repository.RepositoryItemGridLookUpEdit();

            gridLookupEdit.DisplayMember = "Name";

            gridLookupEdit.ValueMember = "EmployeeID";

            gridLookupEdit.DataSource = dtEmployees;

 

            //Change the caption to a column

            gridLookupEdit.View.Columns["Name"].Caption = "Manager Name";

 

            //Hide the "Employee ID" column in GridLookUpEdit

            gridLookupEdit.View.Columns["EmployeeID"].Visible = false;

 

            //Assign it as the editor for a column

            gridView2.Columns["ManagerID"].ColumnEdit = gridLookupEdit;



Regards,