• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

The data to checked listbox is not correct

       CheckedListBox1.DataSource = Me.BindingSource1

        CheckedListBox1.DisplayMember = Me.DataSet1.ITEM.ITM_TYPEColumn.ToString()


When starting the program all i get from the checked listbox is system.data.DataViewManagerListItemTypeDescriptor

Im connecting to a oracle database, and i dont understand why i dont get the Item types in the checked listbox when i start program :/

Please help
0
leeds2000
Asked:
leeds2000
  • 7
  • 5
1 Solution
 
ChumadCommented:
You need to also define the fields where the data comes from...

CheckedListBox1.DataTextField = "someField";
CheckedListBox1.DataValueField = "someotherField";
0
 
leeds2000Author Commented:
uhm, im sorry, i dont quite understand that one, what should i use in the "someField" ?
0
 
leeds2000Author Commented:
also, datatextfield is not a member of the checklistbox1 i get a error saying in visual studio, so i cant use the datatextfield or the datavaluefield
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
ChumadCommented:
Well, for DataTextField, that's what the user sees - the value in the list box. This needs to point to some field or property in DataSet1. Here, I'm going to assume you need to use "ITM_TYPEColumn"

CheckedListBox1.DataTextField = "ITM_TYPEColumn";

Likewise, DataValueField is going to point to the property/field in DataSet1 that contains the value - usually a primary key. You can probably use the same value here if you want "ITM_TYPEColumn"
0
 
ChumadCommented:
Try using DisplayMember instead:

CheckedListBox1.DisplayMember = "ITM_TYPEColumn";
0
 
leeds2000Author Commented:
ok thanks, but i cant use checkedlistbox1.datatextfield, becouse of this error:

'datatextfield' is not a member of system.windows.forms.checkedlistbox

this error is the same for the checkedlistbox1.datavaluefield

0
 
ChumadCommented:
ok, I wasn't aware you were doing windows forms (vs web forms). Try this way:

CheckedListBox1.DisplayMember = "ITM_TYPEColumn"
0
 
leeds2000Author Commented:
oki, well i tried it and i got the same result, is this code supposed to be instead of the .displaymember i already have in my code, or should i add it under my code?

I tried removing my version of the display member, and adding your version, but i got same result. i tried with just yours but i still got same, anything im doing wrong?
0
 
ChumadCommented:
Can you paste all your modified code in here (the version that has the suggested changes)?
0
 
leeds2000Author Commented:
CheckedListBox1.DataSource = Me.BindingSource1

        CheckedListBox1.DisplayMember = Me.DataSet1.ITEM.ITM_TYPEColumn.ToString()

then i add your part of the code

CheckedListBox1.DisplayMember = "ITM_TYPEColumn"

ive also tried removing the CheckedListBox1.DisplayMember = Me.DataSet1.ITEM.ITM_TYPEColumn.ToString()

without any luck
0
 
leeds2000Author Commented:
The error was that i hadnt added a tableadapter to my form :/
0
 
leeds2000Author Commented:
And my code worked as soon as i added this tableadapter, so always check if you have a tableadapter in visual studio 2005 if you cant get any data as soon as your form loads :)
0
 
Vee_ModCommented:
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now