Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / September 2005

Tip: Looking for answers? Try searching our database.

CheckListBox and DataSource

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ken Allen - 06 Sep 2005 20:28 GMT
I have some code that assigns a DataTable to a CheckedListBox to display
which items are selected and which are not. I set the DaatSource to the
DataTable and the DisplayMember to the text column I want displayed, but
nothing is selected.

--> Is there a way to have a column from the DataTable.Rows control
whether an entry is selected or not automatically?

If I manually select entries by walking through the DataTable.Rows and
using SetItemChecked, they are usually displayed properly, but not
always; sometimes none are selected even though the data has elements
selected.

I seem to remember a thread some time ago that discussed this and
indicated that not all controls fully support data binding, and that the
checked list was one of these. I also recall a suggestion that a call at
the form level might assist in resolving this. I tried that on a
project, and it seemed to work. Unfortunately, that was some time ago
and the system on which the work was done was 'destroyed' by some
environmental conditions, and all of the expermental work on that system
was lost.

--> Can anyone recall the magical incantation one can use to aid this
situation, especially when the controls are resident on a tab?

-ken
Claes.Bergefall - 07 Sep 2005 08:34 GMT
See if any of these threads help (long link):

http://groups.google.se/groups?as_q=checkedlistbox+bindingcontext&num=10&scoring
=r&hl=sv&as_epq=&as_oq=&as_eq=&as_ugroup=*dotnet*&as_usubject=&as_uauthors=Claes
+Bergefall&lr=&as_drrb=q&as_qdr=&as_mind=1&as_minm=1&as_miny=1981&as_maxd=7&as_m
axm=9&as_maxy=2005


  /claes

>I have some code that assigns a DataTable to a CheckedListBox to display
>which items are selected and which are not. I set the DaatSource to the
[quoted text clipped - 20 lines]
>
> -ken
Ken Allen - 07 Sep 2005 13:03 GMT
Yes, when the checked list box is on a tab this helps.

In this specific case the checked list box is on the main form, and in
one case simply within a group box on the main form, and it is not
visible until the user makes a selection that will display information.
I have noticed that this works, except for the first time when the
selections are made before the control is drawn for the first time.
Would you expect this same solution to work in that case as well?

Also, is there no mechanism to permit the checked list box to determine
the entries that are to be selected automatically from the data source?
Must one always make a pass through the entries and manually set which
entries are to be selected and which are not?

-ken

> See if any of these threads help (long link):
>
[quoted text clipped - 26 lines]
>>
>>-ken
Claes.Bergefall - 08 Sep 2005 09:44 GMT
> Yes, when the checked list box is on a tab this helps.
>
[quoted text clipped - 4 lines]
> made before the control is drawn for the first time. Would you expect this
> same solution to work in that case as well?

Probably not. The bindingcontext problems only appears with
the tab control afaik.

> Also, is there no mechanism to permit the checked list box to determine
> the entries that are to be selected automatically from the data source?
> Must one always make a pass through the entries and manually set which
> entries are to be selected and which are not?

As far as I know you need to select them manually.

Personally I'm not a big fan on data binding so I tend not to use
it much. There's to much weird stuff going on in the background
for my liking.

You might be better off not using databinding with the CheckedListBox
class. It doesn't really seem ready for that yet. I you check the
docs for CheckedListBox.DataSource you will notice it says "not intended
to be used directly from your code". Same goes for DisplayMember and
ValueMember

   /claes

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.