Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to databind a CheckedListBox control

How to databind a CheckedListBox control

Scheduled Pinned Locked Moved C#
helpcsharpwpfwcftutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abhishk2001 yahoo com
    wrote on last edited by
    #1

    First let me thank you guys, for sharing your knowledge and for responding. I am a newbie learning .NET, so plz bear with me. my question is, how to bind a CheckedListBox control in a WinForm. I did the binding, but it is not showing any values, it's not giving any error either, I wanted the CheckedListBox control to be populated at the FormLoad Event. my code is given below. I tried different ways, but still its not working. lstFacilityType is a CheckedListBox control. First, I tried this. ------------------------------------------------------------------------- lstFacilityType.DataBindings.Add(new Binding("Text",ds,"FacilityType")); ------------------------------------------------------------------------- Second, I tried the code given below, it is returning the table in the dataset. ------------------------------------------------------------------------ lstFacilityType.DataBindings.Add(new Binding("Text",ds.Tables[0],"FacilityType")); ------------------------------------------------------------------------ Thanks, for ur help. abhi

    H 1 Reply Last reply
    0
    • A abhishk2001 yahoo com

      First let me thank you guys, for sharing your knowledge and for responding. I am a newbie learning .NET, so plz bear with me. my question is, how to bind a CheckedListBox control in a WinForm. I did the binding, but it is not showing any values, it's not giving any error either, I wanted the CheckedListBox control to be populated at the FormLoad Event. my code is given below. I tried different ways, but still its not working. lstFacilityType is a CheckedListBox control. First, I tried this. ------------------------------------------------------------------------- lstFacilityType.DataBindings.Add(new Binding("Text",ds,"FacilityType")); ------------------------------------------------------------------------- Second, I tried the code given below, it is returning the table in the dataset. ------------------------------------------------------------------------ lstFacilityType.DataBindings.Add(new Binding("Text",ds.Tables[0],"FacilityType")); ------------------------------------------------------------------------ Thanks, for ur help. abhi

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      If you're trying to bind the actual list, you need to need to fill the Items property manually. Binding the Text only binds the Text property. You should read about the DataBindings property and the BindingManagerBase class in the .NET Framework SDK. The code you're doing above needs to bind to the Text property of the control for which the Binding is added (i.e., lstFacilityType). The rest of your expressions won't work, however, because the Binding only works for PropertyManager, not to bind to an IListSource or IList, of which DataSet and DataTable are (respectively). When you bind to a data-bound control like a DataGrid, it nows how to use the DataSource and, optionally, the DataMember to enumerate the collection and bind a UI element to that row. Binding how you're doing it is not the same. The results you're getting are to be expected since you're binding against an object, not its value. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups