Skip to content

convert string to checkbox

New Discussion
Theresa Watson
Theresa Watson asked on Apr 28, 2016 7:19 PM

I am new to infragistics. I have an ultracombo wingrid that is being populated with a sql dataset.

One of the columns is an string and I need to convert it to a checkbox and pass the value when the checkbox is changed. It is set to a valuelist

I have read through the other forums and still can’t get it to work.

Sign In to post a reply

Replies

  • 0
    Mike Bowshewicz
    Mike Bowshewicz answered on Apr 26, 2016 8:57 PM

    Hi Theresa,

    You can accomplish this by using a DataFilter.

    • 0
      Theresa Watson
      Theresa Watson answered on Apr 26, 2016 9:35 PM

      I have been working with that code but It references using "use an UltraCheckEditor as the Column's EditorControl and specify the DataFilter on the UltraCheckEditor rather than the Column's Editor"

      In my ds I have a Boolean value that I need to convert to string Yes/No and a string field that I need to convert to boolean

      • 0
        Theresa Watson
        Theresa Watson answered on Apr 27, 2016 4:30 PM

        Basically I am not following how to use the UltraCheckEditor  since I have two columns that I need to filter

      • 0
        Mike Bowshewicz
        Mike Bowshewicz answered on Apr 27, 2016 5:12 PM

        Hi Theresa,

        I wrote a sample project that handles both conversions. To treat the string column as a checkbox, I used the same approach as the knowledge base article. To treat the boolean column as a string, I wrote a new DataFilter. The sample is attached.

      • 0
        Theresa Watson
        Theresa Watson answered on Apr 27, 2016 5:36 PM

        I am writing in vb and you provided c#, anyway you can convert?

        And just so I am making myself clear.  I have a Boolean in my dataset that I want to convert to "Yes"/"No".  And in another column I have a String field with two values (not "Yes"/"No") that I am converting to Boolean.

        I have successfully changed the later in CheckEditorDataFilter but I can't apply that to the Boolean field because the values are different.

        Public Function Convert(ByVal args As Infragistics.Win.EditorDataFilterConvertArgs) As Object Implements Infragistics.Win.IEditorDataFilter.Convert

        Select Case args.Direction

        Case ConversionDirection.EditorToOwner

        args.Handled = True

        Select Case CType(args.Value, CheckState)

        Case CheckState.Checked

        Return "35"

        Case CheckState.Unchecked

        Return "37"

        Case CheckState.Indeterminate

        Return String.Empty

        End Select

        Case ConversionDirection.OwnerToEditor

        args.Handled = True

        If args.Value = "35" Then

        Return CheckState.Checked

        ElseIf args.Value = "37" Then

        Return CheckState.Unchecked

        Else

        Return CheckState.Indeterminate

        End If

        End Select

        End Function

      • 0
        Mike Bowshewicz
        Mike Bowshewicz answered on Apr 27, 2016 5:46 PM

        My recommendation is to use a separate data filter for each column.

        I will convert the sample to VB, and update it to account for your clarifications.

      • 0
        Theresa Watson
        Theresa Watson answered on Apr 28, 2016 1:03 PM

        That is my question. How do I setup different data filters for the two columns? 

      • 0
        Mike Bowshewicz
        Mike Bowshewicz answered on Apr 28, 2016 7:19 PM

        Hi Theresa,

        We actually came up with a solution that doesn’t require setting up a DataFilter for each column. I used a value list instead to map YES/NO to true/false on the boolean column. The sample is in VB and is attached here.

        If you needed to apply a separate DataFilter to each column, you could just define each DataFilter in a separate class, then set each editor’s DataFilter property accordingly.

        Attachments:
  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Theresa Watson
Favorites
0
Replies
8
Created On
Apr 28, 2016
Last Post
9 years, 10 months ago

Suggested Discussions

Tags

Created by

Created on

Apr 28, 2016 7:19 PM

Last activity on

Feb 25, 2026 9:49 AM