Srinivas Miriyala's Blog


Monday, June 27, 2011

UltraGrid: Remove/Change selected Row color

If you want to remove selected row color(by default blue) and preserve your cell colors, follow this procedure.

Private Sub grid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles grid1.InitializeLayout

'Make selected row color to transparant
e.Layout.SelectionOverlayColor = SystemColors.Highlight
'remove slected and active appearance
With e.Layout.Bands(0)
.Override.SelectedAppearancesEnabled = DefaultableBoolean.False
.Override.ActiveAppearancesEnabled = DefaultableBoolean.False
End With

End Sub

Labels: , , , ,

Friday, March 12, 2010

UltraWinGrid Disable Autogenerated Columns

use SetDataBinding method instead of assigning data to DataSource property.

UltraGrid1.SetDataBinding(DataTable1, Nothing, True)

Labels: , ,

Friday, March 5, 2010

Infragistics UltraWinGrid useful tips

Hide group header box:
In grid InitializeLayout event handler, set

e.Layout.GroupByBox.Hidden = True

Hide row selectors:
In grid InitializeLayout event handler, set

e.Layout.Override.RowSelectors = DefaultableBoolean.False

Selecting single row:
In grid InitializeLayout event handler, set

e.Layout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Single

Fixed Columns
In grid InitializeLayout event handler, set

e.Layout.UseFixedHeaders = true;
UltraGrid.Bands[0].Columns[0].Header.Fixed = true;
UltraGrid.Bands[0].Columns[1].Header.Fixed = true;

Change cell button properties/appeacence
In grid InitializeLayout event handler, use

e.Layout.Bands(0).Columns("ButtonCell").CellButtonAppearance

Disable Column Sorting
In grid InitializeLayout event handler, set

with e.Layout
.Override.HeaderClickAction = HeaderClickAction.Select
.Override.SelectTypeCol = SelectType.None
End With

To enable immediate scrolling
In grid InitializeLayout event handler, set

with e.Layout
.ScrollBounds = ScrollBounds.ScrollToFill
.ScrollStyle = ScrollStyle.Immediate
End With

Update datasource for each cell change
In grid InitializeLayout event handler, set

UltraGrid1.UpdateMode = Infragistics.Win.UltraWinGrid.UpdateMode.OnCellChange

To change grid Header Appearance
In grid InitializeLayout event handler, use

UltraGrid1.DisplayLayout.Bands(0).Override.HeaderAppearance property

To disable column swapping, moving,sizing and GroupBy
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Override.AllowColMoving = AllowColMoving.NotAllowed
.Override.AllowColSwapping = AllowColSwapping.NotAllowed
.Override.AllowColSizing = AllowColSizing.None
.Override.AllowGroupBy = DefaultableBoolean.False
End With

Show header text in multi line
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Override.WrapHeaderText = DefaultableBoolean.False
.ColHeaderLines = 2 'two lines
.Columns(0).Header.Caption = "text1" & Environment.NewLine & "text2"
End With

To select a full row if click on any cell
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Override.CellClickAction = CellClickAction.RowSelect
End With

Hide a column
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Columns("ColumnName").Hidden = True
End With

Adding DropDownList column
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Columns("ColumnName").Style = ColumnStyle.DropDownList
.Columns("ColumnName").ValueList = UltraGrid1.DisplayLayout.ValueLists("sample")
End With

' create UltraWinGrid Value List
UltraGrid1.DisplayLayout.ValueLists.Add("sample")
With UltraGrid1.DisplayLayout.ValueLists("sample").ValueListItems

Dim aVLI As New ValueListItem()

aVLI.DataValue = 1
aVLI.DisplayText = "Item 1"
.Add(aVLI)

aVLI = New ValueListItem()
aVLI.DataValue = 2
aVLI.DisplayText = "Item 2"
.Add(aVLI)

aVLI = New ValueListItem()
aVLI.DataValue = 3
aVLI.DisplayText = "Item 3"
.Add(aVLI)

End With


Adding a button column
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Columns(0).Style = ColumnStyle.Button
.Columns(0).ButtonDisplayStyle = UltraWinGrid.ButtonDisplayStyle.Always
End With

To make cell text multi line
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Columns(0).CellMultiLine = DefaultableBoolean.True
End With

UltraGrid1.DisplayLayout.Bands(0).Columns(0).VertScrollBar = True

You may want to increase the default row height of the grid to better illustrate this sample.

UltraGrid1.DisplayLayout.Override.DefaultRowHeight = 800

To change column header text
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Columns(0).Header.Caption = "My header"
End With

To change date column format
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Columns(0).Format = "dd/mm/yyyy hh:mm:ss"
End With

Adding an image to a cell
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Columns(0).CellButtonAppearance.Image = My.Resources.ImageName 'Add an image to resource file to access from My.Resources
End With

To make Editable/Non Editable column
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.Columns(0).CellActivation = Activation.AllowEdit ' to allow edit
.Columns(0).CellActivation = Activation.NoEdit ' to lock the cell
End With

To add a band header
In grid InitializeLayout event handler, set

With UltraGrid1.DisplayLayout.Bands(0).
.HeaderVisible = True
.Header.Caption = "My Header"
.Header.Appearance.TextHAlign = HAlign.Center
End With

To reset the sorted columns when unloading then reloading your data
ultraGrid1.DisplayLayout.Bands[0].SortedColumns.Clear()

Do not show Expansion Indicator when there are no child items/band
In grid InitializeLayout event handler, set

UltraGrid1.DisplayLayout.Bands(0).Override.ExpansionIndicator = ShowExpansionIndicator.CheckOnDisplay

Labels: , , , , , , , ,