ListBox - Items collections and DataSource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Hi Prasad,

I understand you did some Syspro -> MS CRM integration. I wonder if
you wouldn't mind emailing me so we could discuss?
(e-mail address removed).

Thanks.

Prasad said:
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 said:
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
 
Paul,

I have sent you an email.

Prasad

Paul W. said:
Hi Prasad,

I understand you did some Syspro -> MS CRM integration. I wonder if
you wouldn't mind emailing me so we could discuss?
(e-mail address removed).

Thanks.

Prasad said:
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 said:
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
 
Back
Top