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
655
Edit a boolean column displays 'True' or 'False'
posted
I fill a ULTRAGRID with data, which then I want to edit. 
This grid has a column with a boolean data ("ACTIVE" column).
When I load the data, the column appears with a CHECKBOX, which is what I want.
At the time I go into edit mode, column data become text ("True" "False").

To test only create a form and add an UltraGrid and a UltraButton:

Private Sub UltraButton1_Click(sender As System.Object, e As System.EventArgs) Handles UltraButton1.Click

Dim dt As New DataTable

dt.Columns.Add("NAME", System.Type.GetType("System.String"))
dt.Columns.Add("ACTIVE", System.Type.GetType("System.Boolean"))

dt.Rows.Add("One", True)
dt.Rows.Add("Two", False)
dt.Rows.Add("Three", True)
dt.Rows.Add("Four", False)
dt.Rows.Add("Five", True)



UltraGrid1.DataSource = dt

Dim _objEdicionCheck As New Infragistics.Win.UltraWinEditors.UltraCheckEditor

_objEdicionCheck.Style = EditCheckStyle.Check
_objEdicionCheck.Visible = True
UltraGrid1.DisplayLayout.Bands(0).Columns("ACTIVE").Style = UltraWinGrid.ColumnStyle.CheckBox

Dim ucCheck As New Infragistics.Win.UltraWinEditors.UltraControlContainerEditor

Me.Controls.Add(_objEdicionCheck)
ucCheck.EditingControl = _objEdicionCheck
ucCheck.EditingControlPropertyName = "Checked"
UltraGrid1.DisplayLayout.Bands(0).Columns("ACTIVE").EditorComponent = ucCheck

End Sub


If I edit the column (by double click), the cell becomes in a checkbox.. and when I leave the cell, the columns returns to "True" or "False"

Why the column lost the style (EditCheckStyle.Check)?
Parents
  • 469350
    Offline posted

    I don't understand what you are trying to do here.

    Are you saying that you want the cell to show a CheckBox all the time? Or you only want it to show a CheckBox when it is in edit mode?

    When do you want a CheckBox and when do you want text?

    The Style property of the column just assigns a default editor to that column. Once you assign an Editor to that column, you are basically overriding the Style property so Style no longer has any effect. So there is no reason to set both.

  • 655
    Offline posted in reply to Mike Saltzman

    Mike

    I want always show a check box, both in edit mode and in read-only mode

    I have a new example form:

    When I press "Load Data", grid show results as follow:

    After I want to edit this results. I press "Edit" and the column changes to Text..Why?

    But when I click over the column to edit, the column become a checkbox.

     

    The code of this new form is

        Private Sub Edit_Click(sender As System.Object, e As System.EventArgs) Handles Edit.Click

            'Allow to edit
            UltraGrid1.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.True

            'Create the ControlContainer
            Dim ucCheck As New Infragistics.Win.UltraWinEditors.UltraControlContainerEditor
            'Create the editor object
            Dim _objEditionCheck As New Infragistics.Win.UltraWinEditors.UltraCheckEditor

            _objEditionCheck.Style = EditCheckStyle.Check


            ucCheck.EditingControl = _objEditionCheck
            ucCheck.EditingControlPropertyName = "Checked"
            UltraGrid1.DisplayLayout.Bands(0).Columns("ACTIVE").EditorComponent = ucCheck

        End Sub

        Private Sub LoadData_Click(sender As System.Object, e As System.EventArgs) Handles LoadData.Click
            Dim dt As New DataTable

            dt.Columns.Add("NAME", System.Type.GetType("System.String"))
            dt.Columns.Add("ACTIVE", System.Type.GetType("System.Boolean"))

            dt.Rows.Add("One", True)
            dt.Rows.Add("Two", False)
            dt.Rows.Add("Three", True)
            dt.Rows.Add("Four", False)
            dt.Rows.Add("Five", True)

            'Force the grid to be readonly
            UltraGrid1.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.False
            UltraGrid1.DataSource = dt

        End Sub

    Thx

Reply Children
No Data