Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / Add Bands, Groups, or Rows Programmatically in UltraGrid

Add Bands, Groups, or Rows Programmatically in UltraGrid

New Discussion
ARIEL MAISONET
ARIEL MAISONET asked on Dec 28, 2018 7:35 PM

I am trying to add a new definition to the ultragrid control at run time.

I am not using dataset.

I want something like this

But I don’t know how to make it on code.

My code is:

 

Private Sub ShowOneEmpleado()

ToV = 0 : ToE = 0

SetGridVacUnoSolo()

With UltraGrid1

tbCodigo.Text = lbCodigos.SelectedItem : CodigoEnUso = lbCodigos.SelectedItem

‘mostrar lo pagado de vac y de enf

CalVacacionesUnSolo()

‘calcular cuanto tiene disponible Vac y Enf

CalVacaciones() : If answer = 255 Then answer = 0 : GoTo 90

c1 = Amt : Amt = 0 : If c1 > mi Then c1 = mi

CalEnfermedad() : If answer = 255 Then answer = 0 : GoTo 90

c2 = Amt : Amt = 0 : If c2 > mt Then c2 = mt

‘Totalizar

Dim row As DataRow = dataTable.NewRow()

row(“Fecha Pago”) = “Gran Total”

row(“Número Cheque”) = “”

row(“Horas Vac”) = THV

row(“Pago Vac”) = FormatNumber(ToV, 2)

row(“Horas Enf”) = THE

row(“Pago Enf”) = FormatNumber(ToE, 2)

dataTable.Rows.Add(row)

 

90:   ‘ bind DataTable to UltraWebGrid

.DisplayLayout.Bands(0).Header.Caption = CodigoEnUso & ”     Vac Disponibles: ” & c1 & ”    Enf Disponibles: ” & c2

UltraGrid1.DataSource = dataTable : UltraGrid1.DataBind() : tbCodigo.Enabled = True : ub5.Visible = True : ub11.Visible = True

100:  ub2.Visible = False : ub3.Visible = True : answer = 0

tbCodigo.Enabled = False : lbCodigos.Visible = False

End With

End Sub

 

Private Sub SetGridVacUnoSolo()

Dim bnd As UltraGridBand = UltraGrid1.DisplayLayout.Bands(0)

With UltraGrid1.DisplayLayout

With .Bands(0)

.HeaderVisible = True

.Header.Caption = “VACACIONES Y ENFERMEDAD”

.Header.Appearance.BackColor = Color.CornflowerBlue

.Header.Appearance.ForeColor = Color.White

.Override.AllowUpdate = DefaultableBoolean.False

End With

.Override.CellClickAction = CellClickAction.RowSelect

.Override.RowSelectors = DefaultableBoolean.False

.Override.RowAppearance.BackColor = Color.WhiteSmoke

.Override.RowAlternateAppearance.BackColor = Color.FromArgb(254, 228, 209)

.Override.CellAppearance.TextHAlign = HAlign.Right

.Override.CellAppearance.TextVAlign = VAlign.Middle

.Override.SelectedRowAppearance.BackColor = Color.Beige

.Override.SelectedRowAppearance.ForeColor = Color.Black

.Override.DefaultRowHeight = 30

End With

‘formar la tabla

dataTable.Columns.Clear() : dataTable.Rows.Clear()

UltraGrid1.DataSource = dataTable : UltraGrid1.DataBind() : UltraGrid1.Layouts.Clear()

Dim col As New DataColumn

col = New DataColumn(“Fecha Pago”, GetType(String)) : dataTable.Columns.Add(col)

col = New DataColumn(“Número Cheque”, GetType(String)) : dataTable.Columns.Add(col)

col = New DataColumn(“Horas Vac”, GetType(String)) : dataTable.Columns.Add(col)

col = New DataColumn(“Pago Vac”, GetType(String)) : dataTable.Columns.Add(col)

col = New DataColumn(“Horas Enf”, GetType(String)) : dataTable.Columns.Add(col)

col = New DataColumn(“Pago Enf”, GetType(String)) : dataTable.Columns.Add(col)

col = Nothing

UltraGrid1.DisplayLayout.PerformAutoResizeColumns(True, PerformAutoSizeType.AllRowsInBand)

End sub

 

—————————————————————————————————————————————————————–

I want to show an information on top first line then add another band or group or child, whatever with the rest of the data.

 

Ariel Maisonet

 

Using 17.1

Sign In to post a reply

Replies

  • 0
    Divya Jain
    Divya Jain answered on Dec 26, 2018 7:30 PM

    Hello ,

    Thank you for posting. You can refer these online help documents describing step by steps, how to add row programmatically at runtime.

    https://www.infragistics.com/help/winforms/wingrid-adding-rows-to-wingrid-programmatically

    https://www.infragistics.com/help/winforms/wingrid-adding-new-rows-to-wingrid

    If you need to add more than one row, it is recommended that you add the rows directly to the DataSet for better performance.
    Or for adding single row add a row to a particular band like this :

    Me.UltraGrid1.DisplayLayout.Bands(0).AddNew()
    Me.UltraGrid1.DisplayLayout.Bands(1).AddNew()

    Also for having a hieratical structure of the data , your underline data source should be designed like that.

    Please let me know if you need further assistance.

    Sincerely,
    Divya Jain
    Associate Software Developer

    • 0
      ARIEL MAISONET
      ARIEL MAISONET answered on Dec 27, 2018 1:35 PM

      Hi

       

      It is not working. Sorry

       

      Can you send me a small Project in VB.

       

      I only need one header with few fields

      One row below filling those fields

       

      Then another header below

      And few rows filling the data of that header.

       

      Like:

      Two header

      header:

      Name               | Join Date     | Hours Available

      Ariel Maisonet | 10/20/1954 | 40

      second Header:

      Hours by Month | Amount Paid

      10                           50.00

       

      Can be done?

      • 0
        Divya Jain
        Divya Jain answered on Dec 28, 2018 7:35 PM

        Hello,

        Thank you for the update.As per your request, I created a sample of UltraGrid, binding it with flat data and with the hierarchical data source having two bands.

        On load, I bind the grid with flat data source and on button click I changed the data source to hierarchical data. For hierarchical datasource I created two DataTables, setting the Relationship between these tables in a DataSet and binding the Hierarchical result to the WinGrid.

        This sample is based on this online help document, here we provided the code snippet for c# and VB both . I created a sample using c# and attached it here for your reference.

        https://www.infragistics.com/help/winforms/wingrid-binding-to-program-generated-hierarchical-data

        If you do not want to create a datatable and have tables available in the data source/sql server then refer to this online development guide.

        https://www.infragistics.com/help/winforms/wingrid-binding-wingrid-to-a-hierarchical-data-source-clr2

        Please let me know if you need further assistance.

        WinGrid.zip

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
ARIEL MAISONET
Favorites
0
Replies
3
Created On
Dec 28, 2018
Last Post
7 years, 9 months ago

Suggested Discussions

Tags

Created by

Created on

Dec 28, 2018 7:35 PM

Last activity on

Feb 12, 2026 9:01 AM