473,779 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "ValueMembe r" properties
of the ListBox correctly like below:

lbTechnician.Da taSource = TechnicianDataS et.Tables[0];
bTechnician.Dis playMember = "Name";
lbTechnician.Va lueMember = "Name";

Where "lbTechnici an" 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 9065
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 "ValueMembe r" properties
of the ListBox correctly like below:

lbTechnician.Da taSource = TechnicianDataS et.Tables[0];
bTechnician.Dis playMember = "Name";
lbTechnician.Va lueMember = "Name";

Where "lbTechnici an" 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*******@hotma il.com.

Thanks.

Prasad <Pr****@discuss ions.microsoft. com> wrote in message news:<B5******* *************** ************@mi crosoft.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 "ValueMembe r" properties
of the ListBox correctly like below:

lbTechnician.Da taSource = TechnicianDataS et.Tables[0];
bTechnician.Dis playMember = "Name";
lbTechnician.Va lueMember = "Name";

Where "lbTechnici an" 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*******@hotma il.com.

Thanks.

Prasad <Pr****@discuss ions.microsoft. com> wrote in message news:<B5******* *************** ************@mi crosoft.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 "ValueMembe r" properties
of the ListBox correctly like below:

lbTechnician.Da taSource = TechnicianDataS et.Tables[0];
bTechnician.Dis playMember = "Name";
lbTechnician.Va lueMember = "Name";

Where "lbTechnici an" 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2119
by: mathieu cupryk | last post by:
I have problems with listboxes in the webform2.cs, the textboxes are working well when I do a click on next. I am missing something. It works with the textboxes. Here is the file: using System; using System.Collections; using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Drawing;
2
3426
by: Luca | last post by:
Hello, I'm using a windows form in which there is a standard ListBox control. I want to add/remove objects from the ArrayList associated to the ListBox, and I want the ListBox immediately shows graphically the change: e.g. if I remove an element from the ArrayList object, then that element should not be no more displayed in the list box. Actually i'm using this code below:
1
2893
by: Patty O'Dors | last post by:
Hi I have some code to create an ownerdrawn listbox (derived), and when I add an item to it, the bold text of the first item (the title, 'Collections and Maturities') mysteriously seems to get bunched up at the right, i.e. squashed up! any idea why? The main bit of the code is as such // (in progressReporter.cs) protected struct LBRow //a row of the listbox, whether it be the title or a
6
2881
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset a denormalized mirror of the database, but I'm not having much luck getting the selection logic down (I haven't found a 'hook' where I can access the listbox object as an object to set the listitem's selected property before it gets rendered).. ...
1
2267
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the button_click function because the only way to find the listbox is: (listbox)e.item.findcontrol What s the solution to this problem?
3
4791
by: Joey | last post by:
Hi, I'm trying to add a default item to my listbox but when I do it tells me that it's not defined, could someone tell me the syntax I need to use to get the listbox control to display a default item? I have tried the following: lstStates.Items.Insert(0, new ListItem("By State","0"))
7
4539
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but ASP.Net stuff when I need a Windows Form control. I've seen dual listbox populators in countless Windows applications, and have seen them run very fast, so I figured this would be extremely popular. Here's how it should work:
3
2298
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
1
8305
by: Refugnic | last post by:
I tried to fill a ListBox with a DataSource pointing to an ArrayList. It all works fine...up to one point. The ArrayList is dynamic, which means the contents of it change, during the course of program use. But instead of Updating the ListBox, virtually nothing happens. The items that were written into the ListBox during the first run remain inside the ListBox, assuming the new values of the ArrayList. Obviously, if the new ArrayList is...
0
9633
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10137
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9928
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8959
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7483
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.