Solved

Checked listbox, dont get the database values inside the listbox

Posted on 2007-11-15
8
656 Views
Last Modified: 2012-05-05
CheckedListBox1.DataSource = Me.BindingSource1

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


I have created the Bindingsource and dataset1 using visual studio 2005 tools, no hardcoding. I dont know how to hardcode this into my code.

When starting the program all i get inside 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
Comment
Question by:leeds2000
8 Comments
 
LVL 2

Expert Comment

by:smcdrc
ID: 20292179
CheckedListBox1.DataTextField = "ColumnName"
 CheckedListBox1.DataValueField = "ColumnName"

Replace column name with the names of the columns you want displayed in the checked listbox.
0
 
LVL 2

Expert Comment

by:smcdrc
ID: 20292188
Basically, you need to tell it what columns to use.
0
 
LVL 18

Expert Comment

by:vbturbo
ID: 20292226
try this

       With CheckedListBox1

                .DisplayMember = "ITM_TYPEColumn"
                .ValueMember = "ITM_TYPEColumn"
                .DataSource = DataSet1.Tables("ITEM")

     End With

vbturbo
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Author Comment

by:leeds2000
ID: 20292548
ok the error seemed to be that my form didnt have a tableadapter to it. I got this to show up when added a datagrid view and just deleted it after.

The code i had worked fine too :)

But then another question you might know

i need two lines in the checkedlistbox, like "Customer_first name" and on the same line in the checkbox "customer_lastname"

how can i do this?

ive tried to CheckedListBox1.DisplayMember = Me.DataSet1.ITEM.ITM_TYPEColumn.ToString() & Me.DataSet1.ITEM.ITM_TYPEColumn.ToString()

without any luck, then the "error system.data.DataRowView" appears inside the checkbox when trying this

0
 
LVL 2

Expert Comment

by:smcdrc
ID: 20297870
The easiest way I have found to do this is in the query/stored Proc.  For example:
Select Name, Company, Name + '-'+Company and Name_Company...

0
 
LVL 3

Accepted Solution

by:
leeds2000 earned 0 total points
ID: 20297969
i resolved it by using        


Dim drv As DataRow
Dim rows As DataRowCollection = Dataset.customer.Rows

        For Each drv In rows
            Me.checklistbox.Items.Add(drv(2).ToString() + " " + drv(1).ToString() + " " + drv(3).ToString())
        Next

0
 
LVL 1

Expert Comment

by:Vee_Mod
ID: 20349797
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now