473,587 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

databound listbox question

joe
I actually have 2 questions:

1) Is databinding the fastest way to load a listbox from sqlserver?
speed is crucial and I want to make sure i'm populating it the fastest
way i can

2) Also, i'm having trouble getting the selected items in the
listbox.

Will simply using the Items property (with the index) not give me
access to the value?:

For intIndex = lstStatus.Selec tedIndex To lstStatus.Items .Count - 1
strTest = strTest & lstStatus.Items (intIndex)
Next

what's so frustrating is that i'm actually doing this for Excel using
VSTO and everytime i try to use the .Items(intIndex ) - Excel
completely crashes on me.

anybody point me to an example or hint?

TIA!
Joe
Nov 21 '05 #1
3 1467
Joe,

1) Is databinding the fastest way to load a listbox from sqlserver?
speed is crucial and I want to make sure i'm populating it the fastest
way i can
The time done with reading the rows accoording with the question what
loading of the listbox is the fastest is comparing parts of seconds with
parts of milliseconds.

2) Also, i'm having trouble getting the selected items in the
listbox.

Will simply using the Items property (with the index) not give me
access to the value?:

For intIndex = lstStatus.Selec tedIndex To lstStatus.Items .Count - 1
strTest = strTest & lstStatus.Items (intIndex)
Next

Do you have Option Strict On in top of your program?

Probably you only have to add ".ToString" after that (intIndex)

I hope this helps?

Cor
Nov 21 '05 #2
joe
Cor-
Thank you very much! The .ToString is definitely a step in the right
direction as it's at least keeping Excel from crashing on me, but i'm
still having one problem.

When I use the .ToString, i'm returned "System.Data.Da taRowView" so
i'm assuming it's because it's databound and I must somehow use a
datarowview object to access the value?

any help would be appreciated-

thanks-
joe

On Tue, 23 Nov 2004 09:55:00 +0100, "Cor Ligthert"
<no************ @planet.nl> wrote:
Joe,

1) Is databinding the fastest way to load a listbox from sqlserver?
speed is crucial and I want to make sure i'm populating it the fastest
way i can


The time done with reading the rows accoording with the question what
loading of the listbox is the fastest is comparing parts of seconds with
parts of milliseconds.

2) Also, i'm having trouble getting the selected items in the
listbox.

Will simply using the Items property (with the index) not give me
access to the value?:

For intIndex = lstStatus.Selec tedIndex To lstStatus.Items .Count - 1
strTest = strTest & lstStatus.Items (intIndex)
Next

Do you have Option Strict On in top of your program?

Probably you only have to add ".ToString" after that (intIndex)

I hope this helps?

Cor

Nov 21 '05 #3
Joe,

I think that my thought was that because you where asking it, you had not
binded data to the listbox yet.
and that as well because you where using the item.

Probably because when you use a datasource that is taken for an operation as
you do.

However to keep it in the way you did, this did work for me as well.

\\\
strTest = strTest & DirectCast(List Box1.Items(intI ndex),
DataRowView)("N ame").ToString
///
("Name" is the used datamember so that you have to change for yours)

While I had expect something as
\\\
strTest = strTest & DirectCast(List Box1.DataSource ,
DataView)(intIn dex)("Name").To String
///
What works as well. For "DirectCast(Lis tBox1.DataSourc e, DataView)" you can
directly place the datasource.

I hope it helps?

Cor

"joe" <jo*@nowayjose. com>
Thank you very much! The .ToString is definitely a step in the right
direction as it's at least keeping Excel from crashing on me, but i'm
still having one problem.

When I use the .ToString, i'm returned "System.Data.Da taRowView" so
i'm assuming it's because it's databound and I must somehow use a
datarowview object to access the value?

any help would be appreciated-

thanks-
joe

On Tue, 23 Nov 2004 09:55:00 +0100, "Cor Ligthert"
<no************ @planet.nl> wrote:
Joe,

1) Is databinding the fastest way to load a listbox from sqlserver?
speed is crucial and I want to make sure i'm populating it the fastest
way i can


The time done with reading the rows accoording with the question what
loading of the listbox is the fastest is comparing parts of seconds with
parts of milliseconds.

2) Also, i'm having trouble getting the selected items in the
listbox.

Will simply using the Items property (with the index) not give me
access to the value?:

For intIndex = lstStatus.Selec tedIndex To lstStatus.Items .Count - 1
strTest = strTest & lstStatus.Items (intIndex)
Next

Do you have Option Strict On in top of your program?

Probably you only have to add ".ToString" after that (intIndex)

I hope this helps?

Cor


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
315
by: Job Lot | last post by:
I have worked out how to move items in ListBox, but it doesn't seems to work when the ListBox is bound to a DataSource. It says "Cannot modift the Item Collection when the DataSource property is set." How can i move items when ListBox is populated using DataSource property? thanx
0
1288
by: JB | last post by:
I have a databound listbox that is causing my form to hang when I call the show method. The list box is bound using the following code: _dataView.Table = _data.Tables; lboUsers.DataSource = _dataView; lboUsers.DisplayMember = "FullName"; then when I call form.Show(), the form shows up, but hangs before it draws any of the controls on the...
0
1268
by: Ken Varn | last post by:
I have a strange problem with a databound listbox. It may be because of how I use it, but I am stumped by this behavior. Here is the scenario: I have a multiselect databound listbox that belongs to a panel control. In the Page_Load event, the panel listbox control may be moved from one panel to another depending on selections that the...
4
2300
by: Harold | last post by:
I have read the following article http://www.4guysfromrolla.com/webtech/073101-1.shtml. I added the empty selection as the first option. When I click submit without choosing anything it does not return my empty string but the 2nd value in listbox. When the page reloads it selects the 2nd option by default even thou my Empty field is in the...
1
1198
by: Brian Henry | last post by:
I am working on an data bound list that implements of course IList, IBindingList, IComparer, etc... your basic things your need for data binding type objects... the problem is i got it to work staticly... that is fill it with data then bind it and the data shows up in a listbox like it should... but if i was to add another object to the custom...
2
3831
by: tangokilo | last post by:
Hello and thanks for your help, I have the following Listbox created in VisualStudio 2003 designer, desiring to select multiple entries from that list: ------------------------------- ListBoxUser.Location = New System.Drawing.Point(16, 240) ListBoxUser.Name = "ListBoxUser" ListBoxUser.SelectionMode =...
1
1458
by: Gerwin Berentschot | last post by:
Hi all, I am looking for a databound listbox control that can be as easily used as the listbox control that comes with Ms Access (with as less programming as possible). I would like this listbox to have drag and drop capabilities, column and row format, etc. Does anybody know which control (commercial of non commercial) is suitable for my...
6
6652
by: =?Utf-8?B?SnVzdGlu?= | last post by:
Hello: Does anyone know how I can create a multi-column listbox in VB.Net (Windows)...I am using VS.Net 2003. If there is another control available that can be databound with multiple columns, I would be interested in looking into that as well. Here is the code I have (it cannot display multiple columns)...
3
995
by: Scott McNair | last post by:
Hi, I have two listboxes (we'll call them LB1 and LB2). LB1 and LB2 are both populated from data, with the valuemember bound to the ID, and the displaymember bound to the data's text. I would like to be able to move the items back and forth between LB1 and LB2 by using "<-" and "->" buttons, so databinding is ruled out (since you can't...
0
7920
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...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
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...
0
6626
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...
1
5718
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...
0
3844
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...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
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

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.