Wednesday 29 May 2013

ultra grid control helps and setting code

code for displaying delete conformation 


  Dim row As UltraGridRow

                If CSMsgBox.ShowQuestionMessage("Do you want to delete the data on the grid?", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                    For Each row In Me.UltraGrid1.Selected.Rows

                        row.Delete(False)

                        Me.UltraGrid1.UpdateData()
                    Next
                End If

code for displaying checkbox and text after check box click in ultra grid

 Dim chk As New Infragistics.Win.UltraWinEditors.UltraCheckEditor

 Me.UltraGrid1.DisplayLayout.Bands(0).Columns("ACTIVE").Style = ColumnStyle.CheckBox
        Me.UltraGrid1.DisplayLayout.Bands(0).Columns("ACTIVE").Editor = chk.EditorUltraGrid1.DisplayLayout.Bands(0).Override.CellDisplayStyle = CellDisplayStyle.FormattedText

Ultra Grid: 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 ultragrid.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

code for Auto_fitting columns to ultraGrid's width
first of all import this

Imports Infragistics.Win.UltraWinGrid
Then
Me.UltraGrid1.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns

code for Ultra Grid to select an entire row when a cell is clicked

UltraGrid1.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect
code for Ultra Grid, how to lock cell data - disable editing
' Disable updating on the entire grid
Me.ultraGrid1.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.False



' Enable updating on the root band. This will override the DisplayLayout setting
Me.ultraGrid1.DisplayLayout.Bands(0).Override.AllowUpdate = DefaultableBoolean.False



Code for Multi selection off
 e.Layout.Override.SelectedAppearancesEnabled = DefaultableBoolean.False

If u want on then simply write true in place of false on above line

Code for ADD New Row
if you want at row on buttom then do this
UltraGrid.displaylayout.Override.AllowAddNew=AllowAddNew.FixedAddRowOnBottom

if you want at row on top then do this
UltraGrid.displaylayout.Override.AllowAddNew=AllowAddNew.FixedAddRowOnTop

and so on many properties please explore it

Code for Row Selector
Me.UltraGrid.displaylayout.Bands(0).Override.RowSelectors=DefaultableBoolean.True


Code for delete row from database

Me.UltraGrid.ActiveRow.Delete()

Code for Color the specific column
 in ultragrid InitializeRow event
  e.Row.Cells("cell name here").Appearance.BackColor = Color.Green


Code for Hide row selectors:

in ultragrid InitializeLayout event
e.Layout.Override.RowSelectors = DefaultableBoolean.False

Code for Column Sorting Disable

in ultra grid Initialize Layout event

e.layout.Override.HeaderClickAction = HeaderClickAction.Select
e.layout.Override.SelectTypeCol = SelectType.None


Hide group header box:
In ultra grid grid Initialize Layout

e.Layout.GroupByBox.Hidden = True

code for Hide row selectors:
In ultragridgrid InitializeLayout event

e.Layout.Override.RowSelectors = DefaultableBoolean.False

three properties of the override that control ' on the Override off the DisplayLayout, then these settings apply to the whole ' UltraGrid.

'FOR MODIFY ALLOW OR UPDATE IN ULTRAGRID
Me.ultraGrid1.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.True

'FOR adding and delecting in ultragrid

      Me.ultraGrid1.DisplayLayout.Override.AllowAddNew = AllowAddNew.No
      Me.ultraGrid1.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False

     ' You can set them on a specific band as well. These settings override those
      ' set on the DisplayLayout's Override object for this band.
   Me.ultraGrid1.DisplayLayout.Bands(0).Override.AllowUpdate = DefaultableBoolean.True
      Me.ultraGrid1.DisplayLayout.Bands(0).Override.AllowAddNew = AllowAddNew.No
      Me.ultraGrid1.DisplayLayout.Bands(0).Override.AllowDelete = DefaultableBoolean.False

 ' There are Activation properties on row, column and cells that dictate whether 
      ' associated cells can be modified, or can even enter in edit mode.
  Dim column As UltraGridColumn = Me.ultraGrid1.DisplayLayout.Bands(0).Columns("CustomerID")
      Dim row As UltraGridRow = Me.ultraGrid1.Rows(0)

' Set the CellActivation off the column something other than AllowEdit to prevent
  ' the user from modifying cells in that column. ActivateOnly allows the user to 
  ' go into edit mode so the user can select and copy text, however the cell will
      ' be read-only thus preventing any data modification.
      column.CellActivation = Activation.ActivateOnly

      ' You can override cell activation setting for a particular row. 
      row.Activation = Activation.ActivateOnly

      ' Furthermore you can override activation on a cell as well.
      row.Cells(column).Activation = Activation.AllowEdit


 code for Selecting single row:
In ultragridgrid InitializeLayout event

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

code for made Fixed Columns
In ultragridgrid InitializeLayout event

e.Layout.UseFixedHeaders = true
UltraGrid.Bands[0].Columns[0].Header.Fixed = true
UltraGrid.Bands[0].Columns[1].Header.Fixed = true
                               OR
Me.UltraGrid.displaylayout.override.AllowCalSizing=AllowCalSizing.None

code for made Fixed Row
Me.UltraGrid.displaylayout.override.RowSizing=RowSizing.Fixed

Change cell button properties/appeacence
In ultragridgrid InitializeLayout event

e.Layout.Bands(0).Columns("name of cell write here").CellButtonAppearance

code for Disable Column Sorting
In ultragridgrid InitializeLayout event


e.Layout.Override.HeaderClickAction = HeaderClickAction.Select
e.Layout.Override.SelectTypeCol = SelectType.None

code to enable immediate scrolling

In ultragridgrid InitializeLayout event

e.Layout.ScrollBounds = ScrollBounds.ScrollToFill
e.Layout.ScrollStyle = ScrollStyle.Immediate


code  for Update datasource for each cell change
In ultragridgrid InitializeLayout event

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

code if you want To change grid Header Appearance

In ultragridgrid InitializeLayout event

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

code if you want To disable column swapping, moving,sizing and GroupBy
In ultragridgrid InitializeLayout event

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


code for Show header text in multi line

In ultragridgrid InitializeLayout event


UltraGrid1.DisplayLayout.Bands(0).Override.WrapHeaderText = DefaultableBoolean.False
UltraGrid1.ColHeaderLines = 2 'two lines
UltraGrid1.Columns(0).Header.Caption = "here write text" & Environment.NewLine & "here write text"


code to select a full row if click on any cell
In ultragrid InitializeLayout event

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

code for Hide a column
In ultragrid InitializeLayout event
UltraGrid1.DisplayLayout.Bands(0).Columns("here write column name").Hidden = True


code for Adding DropDownList column
In ultragrid InitializeLayout event


UltraGrid1.DisplayLayout.Bands(0).Columns("here write ColumnName").Style = ColumnStyle.DropDownList
UltraGrid1.DisplayLayout.Bands(0).Columns("here write ColumnName").ValueList = UltraGrid1.DisplayLayout.ValueLists("my list")

' now create ultragrid list
UltraGrid1.DisplayLayout.ValueLists.Add("my list")
UltraGrid1.DisplayLayout.ValueLists("my list ").ValueListItems

Dim list As New ValueListItem()

list.DataValue = 1
list.DisplayText = "car"
.Add(list)

list= New ValueListItem()
list.DataValue = 2
list.DisplayText = "bus"
.Add(list)

list= New ValueListItem()
list.DataValue = 3
list.DisplayText = "train"
.Add(list)


list= New ValueListItem()
list.DataValue = 4
list.DisplayText = "motor cycle"
.Add(list)



code for Adding a button column
In ultragrid InitializeLayout event

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


code for make cell text multi line
In ultragridgrid InitializeLayout event

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


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

code for reset the sorted columns when unloading
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
'code for increasing the default row height of the ultra grid

UltraGrid1.DisplayLayout.Override.DefaultRowHeight = 500

'code for change column header text
In ultragrid InitializeLayout event

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

code for change date column format
In ultragrid InitializeLayout event

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


code for Adding an image to a cell
In ultragrid InitializeLayout event
now you Add an image to resource file to access from My.Resources here in the below code
UltraGrid1.DisplayLayout.Bands(0).Columns(0).CellButtonAppearance.Image = My.Resources.img

'img is the name image

'code for make Non Editable column and Editable column

'In ultragrid InitializeLayout event
'for code to allow if u want edit

UltraGrid1.DisplayLayout.Bands(0).Columns(0).CellActivation = Activation.AllowEdit

'code for locking the cell
UltraGrid1.DisplayLayout.Bands(0).Columns(0).CellActivation = Activation.NoEdit

code To add a band header
In ultragrid InitializeLayout event
'for header visibility true
UltraGrid1.DisplayLayout.Bands(0).HeaderVisible = True

' code for gave header name
UltraGrid1.DisplayLayout.Bands(0).Header.Caption = "My Header name is write here "

'code for aligning the header text appearence
UltraGrid1.DisplayLayout.Bands(0).Header.Appearance.TextHAlign = HAlign.right

'there are also other alignment setting in ultragrid


No comments:

Post a Comment