Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
445
updating grid cell text
posted

Hello,

OK, so here is he situation.  I am dynamically creating grids and rows using InitializeRow event. In one cell I have an ultracombo with an editor button filled with values for that cell. Here is the code:

oSQL = "Select Description, CAST(LocationId as varchar(50)) as LocationId from Locations where AddressId='" & AddressId & "' "
                                        'oSQL &= " AND LocationBaseid IS NULL"    

                                        If e.Row.Cells.Exists("Location Base") AndAlso Not IsDBNull(e.Row.Cells("Location Base").Value) Then
                                            oSQL &= " AND LocationBaseId='" & e.Row.Cells("Location Base").Value.ToString & "'"
                                            'oSQL &= " AND LocationBaseId='" & CType(e.Row.Cells("Location Base").EditorComponent, UltraWinGrid.UltraCombo).SelectedRow.Cells("LocationBaseId").Value.ToString & "'"
                                        ElseIf e.Row.Cells.Exists("Location Base") Then
                                            oSQL &= " AND LocationBaseId IS NULL" '& e.Row.Cells("Location Base").Value.ToString & "'"
                                        End If
                                        oSQL &= " order by Description"
                                        Dim cboType As New Infragistics.Win.UltraWinGrid.UltraCombo
                                        Dim EditorButton2 As Infragistics.Win.UltraWinEditors.EditorButton = New Infragistics.Win.UltraWinEditors.EditorButton("ShowQ")
                                        EditorButton2.Key = "AddLoc"
                                        EditorButton2.Text = "..."
                                        EditorButton2.Tag = Array.CreateInstance(GetType(String), 4)
                                        EditorButton2.Tag(0) = oRow("ColumnName").ToString
                                        EditorButton2.Tag(1) = e.Row.GetCellValue("InspectionId").ToString
                                        EditorButton2.Tag(2) = e.Row.GetCellValue("ItemId").ToString
                                        Dim utToolTip As New Infragistics.Win.UltraWinToolTip.UltraToolTipInfo
                                        utToolTip.ToolTipTextFormatted = "<span style='font-weight:bold; text-decoration:none;'>Click the '...' button to add a new" & LocationAlias & "<br/><hr/></span>"
                                        uttMain.SetUltraToolTip(cboType, utToolTip)

                                        cboType.ButtonsRight.Add(EditorButton2)
                                        AddHandler cboType.EditorButtonClick, AddressOf EditorButtonClick
                                        With cboType
                                            .DisplayMember = "Description"
                                            .ValueMember = "LocationId"
                                            .DataSource = eData.GetDataTable2(GetConnectionString, oSQL)
                                            .DisplayLayout.Bands(0).Columns("LocationId").Hidden = True
                                        End With
                                        cboType.DisplayLayout.ScrollBounds = UltraWinGrid.ScrollBounds.ScrollToFill

                                        If TestUserSetting("SGFontSize") Then
                                            cboType.DisplayLayout.Override.RowAppearance.FontData.SizeInPoints = cUserSettings("SGFontSize")
                                        Else
                                            cboType.DisplayLayout.Override.RowAppearance.FontData.SizeInPoints = 8.25
                                        End If
                                        SetDropDownWidth(cboType, "Description")
                                        e.Row.Cells(oRow("ColumnName").ToString).Column.Width = cboType.Width
                                        e.Row.Cells(oRow("ColumnName").ToString).EditorComponent = cboType

The editor button on the drop down opens a new form to allow for a new location to be created and added to the drop down. When I come back from the form I want the location created to be the value for the cell. Here is the code from the EditorButton click event:

    Private Sub EditorButtonClick(sender As Object, e As Win.UltraWinEditors.EditorButtonEventArgs)
        Dim curCBO As Infragistics.Win.UltraWinGrid.UltraCombo = sender
        Dim curButton As Infragistics.Win.UltraWinEditors.EditorButton = curCBO.ButtonsRight(0)
        Dim oSQL As String

        Try

...

ElseIf curButton.Tag(0).ToString = LocationAlias Then
                    Dim eRow As Infragistics.Win.UltraWinGrid.UltraGridRow = CType(e.Context, Win.UltraWinGrid.UltraGridCell).Row
                    Dim oForm As New frmLocation

                    oForm.AddressId = AddressId
                    oForm.txtAddress.Text = lblAddress.Text
                    oForm.ucboDescription.Text = eRow.Cells(LocationAlias).Text
                    If eRow.Cells(LocationAlias).Text <> "" AndAlso TypeOf eRow.Cells(LocationAlias).Value Is Guid Then
                        oForm.PrimaryKey = eRow.Cells(LocationAlias).Value.ToString
                    End If
                    If eRow.Cells.Exists("Location Base") AndAlso eRow.Cells("Location Base").Value IsNot Nothing AndAlso Not IsDBNull(eRow.Cells("Location Base").Value) Then
                        'SetSelectedRow(oForm.ucboLocationBase, "LocationBaseId", UCase(eRow.Cells("Location Base").Value.ToString))
                        oForm.LocationBaseId = eRow.Cells("Location Base").Value.ToString
                    End If
                    oForm.ShowDialog()
                    If Not oForm.PrimaryKey Is Nothing Then
                        Audit.SubRecordAudit(oForm.cboLocationType.Text, oForm.PrimaryKey, "Locations", clsAudit.SubRecordAuditTypes.AddRecord)
                        ISDirty = True
                        'oSQL = "Select LocationBase, Cast(LocationBaseId as varchar(50)) as LocationBaseId from LocationBases where AddressId='" & AddressId & "' order by LocationBase"
                        If eRow.Cells.Exists("Location Base") Then

                            Dim cboType As Infragistics.Win.UltraWinGrid.UltraCombo = CType(eRow.Cells("Location Base").EditorComponent, Win.UltraWinGrid.UltraCombo)
                            'eRow.Cells("Location Base").SetValue(DBNull.Value, True)
                            'cboType.DataSource = Nothing
                            'With cboType
                            '    .DisplayMember = "LocationBase"
                            '    .ValueMember = "LocationBaseId"
                            '    .DataSource = eData.GetDataTable2(GetConnectionString, oSQL)
                            '    .DisplayLayout.Bands(0).Columns("LocationBaseId").Hidden = True
                            'End With
                            'SetDropDownWidth(cboType, "LocationBase")
                            'cboType.DisplayLayout.ScrollBounds = UltraWinGrid.ScrollBounds.ScrollToFill
                            'eRow.Cells("Location Base").EditorComponent = cboType
                            SetSelectedRow(cboType, "LocationBaseId", UCase(oForm.LocationBaseId))
                            eRow.Cells("Location Base").SetValue(UCase(oForm.LocationBaseId), True)
                        End If
                        oSQL = "Select Description, LocationId from Locations where AddressId='" & AddressId & "' "
                        'oSQL &= " AND LocationBaseid IS NULL"
                        If eRow.Cells.Exists("Location Base") AndAlso Not IsDBNull(eRow.Cells("Location Base").Value) Then
                            oSQL &= " AND LocationBaseId='" & eRow.Cells("Location Base").Value.ToString & "'"
                        ElseIf eRow.Cells.Exists("Location Base") Then
                            oSQL &= " AND LocationBaseId IS NULL" '& e.Row.Cells("Location Base").Value.ToString & "'"
                        End If
                        oSQL &= " order by Description"
                        Dim NewLoc As String = eRow.Cells(LocationAlias).Text
                        eRow.Cells(LocationAlias).SetValue(DBNull.Value, True)
                        'curCBO.DataSource = Nothing
                        With curCBO
                            .DisplayMember = "Description"
                            .ValueMember = "LocationId"
                            .DataSource = eData.GetDataTable2(GetConnectionString, oSQL)
                            .DisplayLayout.Bands(0).Columns("LocationId").Hidden = True
                        End With
                        curCBO.DisplayLayout.ScrollBounds = UltraWinGrid.ScrollBounds.ScrollToFill
                        SetDropDownWidth(curCBO, "Description")
                      
                        EBClick = True
Here is my problem
                        SetSelectedRow(CType(eRow.Cells(LocationAlias).EditorComponent, Infragistics.Win.UltraWinGrid.UltraCombo), "Description", NewLoc)
                        eRow.Cells(LocationAlias).Value = oForm.PrimaryKey
                       
                        EBClick = False
                    End If
                    If oForm IsNot Nothing Then oForm.Dispose()

What I get is not the Text description but the guid in the field that is hidden in the combo.

What am I doing wrong.

Any help would be great.

Thanks.