How to populate "custom" text into ChildRadGridView

2 posts, 0 answers
  1. hkdave95
    hkdave95 avatar
    245 posts
    Member since:
    Nov 2006

    Posted 22 May 2008 Link to this post

    Hi

    How do I use RowFormatting to populate "custom" text into a ChildRadGridView ?

    The following code populates the MasterGridView properly but my commented out code causes the program to fall over in a heap.

    Private Sub rgvInvoices_RowFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles rgvInvoices.RowFormatting  
            Dim loUserRow As _the_dl_outletDataSet.UsersRow = Me._the_dl_outletDataSet.Users.FindByU_nId(CType(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_U_nId").Value, System.Int64))  
            If loUserRow IsNot Nothing Then  
                CType(e.RowElement.RowInfo.Cells("sCustomerName").CellElement, Telerik.WinControls.UI.GridCellElement).Text = loUserRow.U_sLastName & ", " & loUserRow.U_sFirstName  
            End If  
            CType(e.RowElement.RowInfo.Cells("sBillingAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text = CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingAddress1").Value) & vbNewLine  
            If String.IsNullOrEmpty(CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingAddress2").Value)) Then  
                CType(e.RowElement.RowInfo.Cells("sBillingAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text &= CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingAddress2").Value) & vbNewLine  
            End If  
            CType(e.RowElement.RowInfo.Cells("sBillingAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text &= CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingCity").Value) & vbNewLine & CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingCounty").Value) & vbNewLine & CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingPostCode").Value) & vbNewLine & CStr(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_sBillingCountry").Value)  
            Dim loDeliveryAddressRow As _the_dl_outletDataSet.DeliveryAddressesRow = Me._the_dl_outletDataSet.DeliveryAddresses.FindByDA_nId(CType(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("I_DA_nId").Value, System.Int64))  
            If loDeliveryAddressRow IsNot Nothing Then  
                CType(e.RowElement.RowInfo.Cells("sDeliveryAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text = loDeliveryAddressRow.DA_sAddress1 & vbNewLine  
                If loDeliveryAddressRow.IsDA_sAddress2Null Then  
                    CType(e.RowElement.RowInfo.Cells("sDeliveryAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text &= loDeliveryAddressRow.DA_sAddress2 & vbNewLine  
                End If  
                CType(e.RowElement.RowInfo.Cells("sDeliveryAddress").CellElement, Telerik.WinControls.UI.GridCellElement).Text &= loDeliveryAddressRow.DA_sCity & vbNewLine & loDeliveryAddressRow.DA_sCounty & vbNewLine & loDeliveryAddressRow.DA_sPostCode & vbNewLine & loDeliveryAddressRow.DA_sCountry  
            End If  
            'Select Case CType(sender, Telerik.WinControls.UI.RadGridView).Name  
            '    Case "rgvInvoices"  
            '    Case "rgvAuditTrail"  
            '        Select Case CType(Me.rgvInvoices.Rows(e.RowElement.ViewInfo.CurrentIndex).Cells("AT_nType").Value, _Enum.AuditTrailTypes)  
            '            Case AuditTrailTypes.OrderPlaced  
            '                CType(e.RowElement.RowInfo.Cells("sType").CellElement, Telerik.WinControls.UI.GridCellElement).Text = "Order Placed" 
            '            Case AuditTrailTypes.OrderCancelled  
            '                CType(e.RowElement.RowInfo.Cells("sType").CellElement, Telerik.WinControls.UI.GridCellElement).Text = "Order Cancelled" 
            '            Case AuditTrailTypes.PaymentUnverified  
            '                CType(e.RowElement.RowInfo.Cells("sType").CellElement, Telerik.WinControls.UI.GridCellElement).Text = "Payment unverified" 
            '            Case AuditTrailTypes.PaymentVerified  
            '                CType(e.RowElement.RowInfo.Cells("sType").CellElement, Telerik.WinControls.UI.GridCellElement).Text = "Payment verified" 
            '            Case Else  
            '                CType(e.RowElement.RowInfo.Cells("sType").CellElement, Telerik.WinControls.UI.GridCellElement).Text = "Unknown Audit Trail entry" 
            '        End Select  
            'End Select  
        End Sub 

    Any ideas ?

    Kind Regards

    David
  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 26 May 2008 Link to this post

    Hi hkdave95,

    Thank you for writing.

    In general, there is no problem with your approach. You should use the CellFormating instead of the RowFormating event, because you need to edit the value of every cell. CellFormating is fired for all visible cells in the RadGridView and you should use it when setting custom cell formatting, value or appearance.

    If you need additional assistance, do not hesitate to contact me again.

    Greetings,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top