473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.SelectedIndex 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 1446
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.SelectedIndex 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.DataRowView" 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.SelectedIndex 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(ListBox1.Items(intIndex),
DataRowView)("Name").ToString
///
("Name" is the used datamember so that you have to change for yours)

While I had expect something as
\\\
strTest = strTest & DirectCast(ListBox1.DataSource,
DataView)(intIndex)("Name").ToString
///
What works as well. For "DirectCast(ListBox1.DataSource, 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.DataRowView" 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.SelectedIndex 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
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...
0
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 =...
0
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...
4
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...
1
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...
2
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: -------------------------------...
1
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...
6
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...
3
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.