How to Populate CheckBoxList from Code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bishop

    How to Populate CheckBoxList from Code

    I'm trying to find out how to populate a CheckBoxList from code without
    using a database.

    The following code generates 6 unchecked checkboxes without any text.
    Dim x As Integer

    For x = 0 To 5

    Dim myCheckbox As New CheckBox

    myCheckbox.Text = "Test " & x

    myCheckbox.Chec ked = True

    chkProfiles.Ite ms.Add(myCheckb ox)

    Next

    Any thoughts?


  • zacks@construction-imaging.com

    #2
    Re: How to Populate CheckBoxList from Code

    On May 13, 1:13 pm, "Bishop" <nos...@nospam. comwrote:
    I'm trying to find out how to populate a CheckBoxList from code without
    using a database.
    >
    The following code generates 6 unchecked checkboxes without any text.
    Dim x As Integer
    >
    For x = 0 To 5
    >
        Dim myCheckbox As New CheckBox
    >
        myCheckbox.Text = "Test " & x
    >
        myCheckbox.Chec ked = True
    >
        chkProfiles.Ite ms.Add(myCheckb ox)
    >
    Next
    >
    Any thoughts?
    Did you even check the documentation?

    CheckBoxList defined:

    Creates a multi selection check box group that can be dynamically created by binding the control to a data source.


    Comment

    • Bishop

      #3
      Re: How to Populate CheckBoxList from Code

      No because I could not find any for windows application.

      Should have mentioned previously, VB.NET 2005, windows application.

      <zacks@construc tion-imaging.comwrot e in message
      news:d3a9ab8a-8563-49ad-82bf-ca891ee9097c@a7 0g2000hsh.googl egroups.com...
      On May 13, 1:13 pm, "Bishop" <nos...@nospam. comwrote:
      I'm trying to find out how to populate a CheckBoxList from code without
      using a database.
      >
      The following code generates 6 unchecked checkboxes without any text.
      Dim x As Integer
      >
      For x = 0 To 5
      >
      Dim myCheckbox As New CheckBox
      >
      myCheckbox.Text = "Test " & x
      >
      myCheckbox.Chec ked = True
      >
      chkProfiles.Ite ms.Add(myCheckb ox)
      >
      Next
      >
      Any thoughts?
      Did you even check the documentation?

      CheckBoxList defined:

      Creates a multi selection check box group that can be dynamically created by binding the control to a data source.



      Comment

      • zacks@construction-imaging.com

        #4
        Re: How to Populate CheckBoxList from Code

        On May 13, 2:54 pm, "Bishop" <nos...@nospam. comwrote:
        No because I could not find any for windows application.
        >
        Should have mentioned previously, VB.NET 2005, windows application.
        >
        <za...@construc tion-imaging.comwrot e in message
        >
        news:d3a9ab8a-8563-49ad-82bf-ca891ee9097c@a7 0g2000hsh.googl egroups.com...
        On May 13, 1:13 pm, "Bishop" <nos...@nospam. comwrote:
        >
        >
        >
        >
        >
        I'm trying to find out how to populate a CheckBoxList from code without
        using a database.
        >
        The following code generates 6 unchecked checkboxes without any text.
        Dim x As Integer
        >
        For x = 0 To 5
        >
        Dim myCheckbox As New CheckBox
        >
        myCheckbox.Text = "Test " & x
        >
        myCheckbox.Chec ked = True
        >
        chkProfiles.Ite ms.Add(myCheckb ox)
        >
        Next
        >
        Any thoughts?
        >
        Did you even check the documentation?
        >
        CheckBoxList defined:
        >
        http://msdn.microsoft.com/en-us/libr...ebcontrols.che...
        The documentation implies that the CheckBoxList control is not support
        in WinForms, just Web apps.

        Comment

        • =?Utf-8?B?S2VycnkgTW9vcm1hbg==?=

          #5
          Re: How to Populate CheckBoxList from Code

          Bishop,

          Isn't the CheckboxList a web control?

          For a windows forms application, perhaps you can use the CheckedListBox
          control.

          Kerry Moorman


          "Bishop" wrote:
          No because I could not find any for windows application.
          >
          Should have mentioned previously, VB.NET 2005, windows application.
          >
          <zacks@construc tion-imaging.comwrot e in message
          news:d3a9ab8a-8563-49ad-82bf-ca891ee9097c@a7 0g2000hsh.googl egroups.com...
          On May 13, 1:13 pm, "Bishop" <nos...@nospam. comwrote:
          I'm trying to find out how to populate a CheckBoxList from code without
          using a database.

          The following code generates 6 unchecked checkboxes without any text.
          Dim x As Integer

          For x = 0 To 5

          Dim myCheckbox As New CheckBox

          myCheckbox.Text = "Test " & x

          myCheckbox.Chec ked = True

          chkProfiles.Ite ms.Add(myCheckb ox)

          Next

          Any thoughts?
          >
          Did you even check the documentation?
          >
          CheckBoxList defined:
          >
          Creates a multi selection check box group that can be dynamically created by binding the control to a data source.

          >
          >
          >

          Comment

          • kimiraikkonen

            #6
            Re: How to Populate CheckBoxList from Code

            On May 13, 8:13 pm, "Bishop" <nos...@nospam. comwrote:
            I'm trying to find out how to populate a CheckBoxList from code without
            using a database.
            >
            The following code generates 6 unchecked checkboxes without any text.
            Dim x As Integer
            >
            For x = 0 To 5
            >
            Dim myCheckbox As New CheckBox
            >
            myCheckbox.Text = "Test " & x
            >
            myCheckbox.Chec ked = True
            >
            chkProfiles.Ite ms.Add(myCheckb ox)
            >
            Next
            >
            Any thoughts?
            Bishop,
            If your difficulty is to populate checkedListBox( this control is for
            winforms) up to 6 items with text, i hope this is what you want:


            ' Here chkProfiles is your checkedListbox control
            For x As Integer = 0 To 5
            chkProfiles.Ite ms.Add("Test" & x)
            Next

            Thanks,

            Onur Güzel

            Comment

            • Bishop

              #7
              Re: How to Populate CheckBoxList from Code

              Yes, this is what I was looking for, I didn't realise it was different in
              from ASP to Winform. I wanted to add checkbox controls so I could control
              text, if it was checked or not, the value (the not seen one), and the color
              of the checkbox.



              "kimiraikko nen" <kimiraikkonen8 5@gmail.comwrot e in message
              news:64801b86-a833-45d8-b6fe-87c72da4ab53@25 g2000hsx.google groups.com...
              On May 13, 8:13 pm, "Bishop" <nos...@nospam. comwrote:
              I'm trying to find out how to populate a CheckBoxList from code without
              using a database.
              >
              The following code generates 6 unchecked checkboxes without any text.
              Dim x As Integer
              >
              For x = 0 To 5
              >
              Dim myCheckbox As New CheckBox
              >
              myCheckbox.Text = "Test " & x
              >
              myCheckbox.Chec ked = True
              >
              chkProfiles.Ite ms.Add(myCheckb ox)
              >
              Next
              >
              Any thoughts?
              Bishop,
              If your difficulty is to populate checkedListBox( this control is for
              winforms) up to 6 items with text, i hope this is what you want:


              ' Here chkProfiles is your checkedListbox control
              For x As Integer = 0 To 5
              chkProfiles.Ite ms.Add("Test" & x)
              Next

              Thanks,

              Onur Güzel


              Comment

              Working...