Srinivas Miriyala's Blog


Tuesday, March 30, 2010

UltraGrid - Change Header Properties

' Get the band to hide the headers in.
Dim band As UltraGridBand = Me.ultraGrid1.DisplayLayout.Bands(0)

' You can hide the column headers by setting ColHeadersVisible to false. By
' default, column headers are visible.
band.ColHeadersVisible = False

' You can hide the group headers by setting GroupHeadersVisible to false. By
' default, group headers are visible.
band.GroupHeadersVisible = False

' You can also show the band header which by default is hidden by setting
' the HeaderVisible property to true.
band.HeaderVisible = True

' You can also set the caption of the band header.
band.Header.Caption = "Customers Table"

' You can also set the apperance of the band header using Appearance property
' off the header.
band.Header.Appearance.BackColor = Color.DarkBlue
band.Header.Appearance.ForeColor = Color.LightYellow

' You can use the HeaderPlacement property to specify how headers are displayed.
band.Override.HeaderPlacement = HeaderPlacement.FixedOnTop

Friday, March 12, 2010

UltraWinGrid Disable Autogenerated Columns

use SetDataBinding method instead of assigning data to DataSource property.

UltraGrid1.SetDataBinding(DataTable1, Nothing, True)

Labels: , ,

Tuesday, March 9, 2010

UltraWinGrid - Disable sorting on few columns

For example, to enable soring only on Column1 and Column4 :


Private Sub UltraGrid1_BeforeSortChange(ByVal sender As Object, ByVal e As
Infragistics.Win.UltraWinGrid.BeforeSortChangeEventArgs) Handles
ugProblemList.BeforeSortChange

If Not (e.SortedColumns.Exists("Column1") Or
e.SortedColumns.Exists("Column4")) Then
e.Cancel = True
End If

End Sub

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: , , , , , , , ,