Hi, as I browsed, I found that I can use column choose dialog for hiding column functionality that the user can use. But I need to hide certain columns inside the code, not let the user choose it. I assume since the column choose dialog can do it, I should be able to do it too. But can't find any reference. Could you please provide me any directions?
Also, the band and overriden properties, are they only available at design time and through the initializelayout event? Can't I directly access them like any other property?
Thanks in advance.
grdDetails.DisplayLayout.Bands[0].Columns[0].Hidden = true;
this is how to hide any column in your Ultra Grid in Windows Forms.
Regards
Fahad Mirza
Senior .Net Developer
Dear Sari211 --
FYI, this is one way to hide a column in an UltraWinGrid programmatically...
this.myUltraWinGrid.DisplayLayout.Bands[0].Columns[0].Hidden = true;
HTH.
Thanks.
-- Mark Kamoski
Amiram Korach said: To hide a column set column.Header.Hidden = true. You can access the band by grid.DisplayLayout.Bands[0], or 1 or 2 if you have more than one. What do you mean "overriden properties"?
To hide a column set column.Header.Hidden = true.
You can access the band by grid.DisplayLayout.Bands[0], or 1 or 2 if you have more than one.
What do you mean "overriden properties"?
Thanks a lot Amiram. Exactly what I was looking for.
By "overriden properties" I meant the "Override" object. Sorry for the confusion. Following your answer for accessing bands, I can see the same can be used to access Override.
Mike Saltzman said: If you are going to set the hidden property on a column to true, I recommend that you do it in the InitializeLayout event. You can do it anywhere, but this is a good event to use because it fires when the grid's datasource is set.The event is specifically designed for setting up the layout of the grid including (among other things), the visibility of columns. You will probably also want to use the ExcludeFromColumnChooser property on the column to prevent the column from displaying in the ColumnChooser.
If you are going to set the hidden property on a column to true, I recommend that you do it in the InitializeLayout event. You can do it anywhere, but this is a good event to use because it fires when the grid's datasource is set.The event is specifically designed for setting up the layout of the grid including (among other things), the visibility of columns.
You will probably also want to use the ExcludeFromColumnChooser property on the column to prevent the column from displaying in the ColumnChooser.
Thanks a bunch to you too Mike. Yes I do intend to use the initializelayoutevent. Although there will be more to it. I am actually extending the UltraGrid to simulate some properties and events and posibly methods of the DataGridView. I have a huge project and I really really want to use UltraGrid. But the project has a DataGridView on almost every section. If I directly substitute the two controls, I'll have to do a LOT of work to also update the handler sections and what not. Hence my idea of doing it this way.
Thanks to both of you. This is an excellent community :)
Oh and thanks to you too morrisd. Your code gave me a few hints of what I might need to do for something else.
I use the following code in the initialize layout event
Dim
aColumn As UltraGridColumn
For Each aColumn In e.Layout.Bands(0).Columns
Select Case aColumn.Key
Case "Select"
aColumn.Header.Caption = "Select"
aColumn.Header.VisiblePosition = 0
aColumn.Width = 59
aColumn.DataType =
GetType(Boolean)
aColumn.AllowGroupBy = DefaultableBoolean.False
aColumn.Header.Fixed =
True
Case "txtCompanyName"
aColumn.Header.VisiblePosition = 1
aColumn.Header.Caption =
"Company Name"
aColumn.CellAppearance.TextHAlign = HAlign.Left
aColumn.Header.Appearance.TextHAlign = HAlign.Center
aColumn.ExcludeFromColumnChooser = ExcludeFromColumnChooser.False
If Me.grdList.Rows.Count > 0 Then
aColumn.PerformAutoResize(
Me.grdList.Rows.Count)
End If
"Home Phone"
aColumn.MaskInput =
"(###) ###-####"
aColumn.MaskDataMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.Raw
aColumn.MaskClipMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeBoth
aColumn.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeBoth
aColumn.Header.VisiblePosition = 12
Case Else
aColumn.Hidden =
aColumn.ExcludeFromColumnChooser = ExcludeFromColumnChooser.True
End Select
Next
I usually set up the grid appearance before this then use this to set up all the columns. Hope this helps.