468,321 Members | 1,836 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

ListBox - Items collections and DataSource

Hey All,

I am having a little trouble with the ListBox's Items collection property. I
am populating the ListBox with data contained in an SQL table using
SQLDataAdapter and DataSet.

I have set the "DataSource", "DisplayMember", and "ValueMember" properties
of the ListBox correctly like below:

lbTechnician.DataSource = TechnicianDataSet.Tables[0];
bTechnician.DisplayMember = "Name";
lbTechnician.ValueMember = "Name";

Where "lbTechnician" is the name of the ListBox and "Name" is one of the
columns of the SQL table.

The application is compiling with 0 errors and 0 warning. But when I try to
run it JIT (Just-In-Time) Debugging is giving me following error:

"Can't modify the Items collection when the DataSource property is set"

I checked the Items collection for the ListBox. Its empty. I dont have any
idea how to fix this error.

Can anybody help me out.

Thanks in advance,
Prasad



Nov 16 '05 #1
3 7978
FYI --

I fixed it. I had set the "Sorted" property of the ListBox to "true". You
cant use that property if you are using DataSet to populate the ListBox. You
have to use ORDER BY within your SQL Query.

Prasad

"Prasad" wrote:
Hey All,

I am having a little trouble with the ListBox's Items collection property. I
am populating the ListBox with data contained in an SQL table using
SQLDataAdapter and DataSet.

I have set the "DataSource", "DisplayMember", and "ValueMember" properties
of the ListBox correctly like below:

lbTechnician.DataSource = TechnicianDataSet.Tables[0];
bTechnician.DisplayMember = "Name";
lbTechnician.ValueMember = "Name";

Where "lbTechnician" is the name of the ListBox and "Name" is one of the
columns of the SQL table.

The application is compiling with 0 errors and 0 warning. But when I try to
run it JIT (Just-In-Time) Debugging is giving me following error:

"Can't modify the Items collection when the DataSource property is set"

I checked the Items collection for the ListBox. Its empty. I dont have any
idea how to fix this error.

Can anybody help me out.

Thanks in advance,
Prasad



Nov 16 '05 #2
Hi Prasad,

I understand you did some Syspro -> MS CRM integration. I wonder if
you wouldn't mind emailing me so we could discuss?
bu*******@hotmail.com.

Thanks.

Prasad <Pr****@discussions.microsoft.com> wrote in message news:<B5**********************************@microso ft.com>...
FYI --

I fixed it. I had set the "Sorted" property of the ListBox to "true". You
cant use that property if you are using DataSet to populate the ListBox. You
have to use ORDER BY within your SQL Query.

Prasad

"Prasad" wrote:
Hey All,

I am having a little trouble with the ListBox's Items collection property. I
am populating the ListBox with data contained in an SQL table using
SQLDataAdapter and DataSet.

I have set the "DataSource", "DisplayMember", and "ValueMember" properties
of the ListBox correctly like below:

lbTechnician.DataSource = TechnicianDataSet.Tables[0];
bTechnician.DisplayMember = "Name";
lbTechnician.ValueMember = "Name";

Where "lbTechnician" is the name of the ListBox and "Name" is one of the
columns of the SQL table.

The application is compiling with 0 errors and 0 warning. But when I try to
run it JIT (Just-In-Time) Debugging is giving me following error:

"Can't modify the Items collection when the DataSource property is set"

I checked the Items collection for the ListBox. Its empty. I dont have any
idea how to fix this error.

Can anybody help me out.

Thanks in advance,
Prasad



Nov 16 '05 #3
Paul,

I have sent you an email.

Prasad

"Paul W." wrote:
Hi Prasad,

I understand you did some Syspro -> MS CRM integration. I wonder if
you wouldn't mind emailing me so we could discuss?
bu*******@hotmail.com.

Thanks.

Prasad <Pr****@discussions.microsoft.com> wrote in message news:<B5**********************************@microso ft.com>...
FYI --

I fixed it. I had set the "Sorted" property of the ListBox to "true". You
cant use that property if you are using DataSet to populate the ListBox. You
have to use ORDER BY within your SQL Query.

Prasad

"Prasad" wrote:
Hey All,

I am having a little trouble with the ListBox's Items collection property. I
am populating the ListBox with data contained in an SQL table using
SQLDataAdapter and DataSet.

I have set the "DataSource", "DisplayMember", and "ValueMember" properties
of the ListBox correctly like below:

lbTechnician.DataSource = TechnicianDataSet.Tables[0];
bTechnician.DisplayMember = "Name";
lbTechnician.ValueMember = "Name";

Where "lbTechnician" is the name of the ListBox and "Name" is one of the
columns of the SQL table.

The application is compiling with 0 errors and 0 warning. But when I try to
run it JIT (Just-In-Time) Debugging is giving me following error:

"Can't modify the Items collection when the DataSource property is set"

I checked the Items collection for the ListBox. Its empty. I dont have any
idea how to fix this error.

Can anybody help me out.

Thanks in advance,
Prasad



Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by mathieu cupryk | last post: by
2 posts views Thread by Luca | last post: by
1 post views Thread by Patty O'Dors | last post: by
6 posts views Thread by Chris Leuty | last post: by
7 posts views Thread by Dave | last post: by
3 posts views Thread by Ali Chambers | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by howard w | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.