473,761 Members | 5,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Returning the index number of listbox

Hi,

Does anyone know how I can return the index number of a ListBox?

Ex. How do I use lbxMyListBox.It ems.IndexOf to search for the item that has
a Text="Name"

Thanks
Maz.
Nov 19 '05 #1
2 1758
Jon
Could you not do this whith a foreach?

Jon

"Maziar Aflatoun" wrote:
Hi,

Does anyone know how I can return the index number of a ListBox?

Ex. How do I use lbxMyListBox.It ems.IndexOf to search for the item that has
a Text="Name"

Thanks
Maz.

Nov 19 '05 #2
Dim index As Integer =
lbxMyListBox.It ems.IndexOf(lbx MyListBox.Items .FindByText("Na me"))

If you need to look for a value instead of text, use FindByValue method

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Maziar Aflatoun" <ma***@rogers.c om> wrote in message
news:Xu******** ************@ro gers.com...
Hi,

Does anyone know how I can return the index number of a ListBox?

Ex. How do I use lbxMyListBox.It ems.IndexOf to search for the item that
has a Text="Name"

Thanks
Maz.

Nov 19 '05 #3

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

Similar topics

1
1479
by: don | last post by:
Ref Dvd Title Location ---------------------------------------- 62 Pilates; Austin Binder 1 63 Yoga; Kripalu Binder 1 64 Yoga; Workout Binder 1 93 The Sopranos Binder 1 94 The Sopranos Binder 2 95 The Sopranos Binder 3
6
2235
by: Young J. Putt | last post by:
I've got a list box bound to a Datatable, like this: lstProjects.DataSource = m_oProjectSet.DataTable lstProjects.DisplayMember = "ProjectDesc" lstProjects.ValueMember = "ProjectID" I want to pass the ProjectID value (integer) of the selected item in lstProjects to another function. I assumed I could reference the integer value of the ProjectID column as
3
4299
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: self.fonts=list(tkFont.families()) self.fonts.sort() for item in self.fonts: self.fontlist.insert(END, item) #self.fontlist is the
0
964
by: rahulnag22 | last post by:
Hi, I am using a listbox in selectmode = MULTIPLE, I can get the current selected item in the listbox from index = "ACTIVE" , but is there a way to convert this "ACTIVE" to get the current selection index as a number. For multiple selectmode listboxes it returns a tuple of selected indexes, so I would have to write some extra code to get the current active selection index from the tuple, instead I was hoping there would be a way to get...
1
3431
by: stimul8d | last post by:
okay; ASP. I have i listbox inside a user control which is dynamically created on page_init. I check for postback and only populate the datasource if it's false. regardless, i do this foreach (Product p in manager.Products) { ASP.MasterDetailDropDown productMasterDetail; productMasterDetail = (ASP.MasterDetailDropDown)LoadControl("~/controls/MasterDetailDropDown.ascx"); ...
2
4833
by: GS | last post by:
I want to create a dropdownlistbox in my windows form with name value pair. but I need to initialize its initial selected value to a value from database for the record. I was going to just use the listbox and find in the view source the record number as index. but it did not work consistently. it worked for the first listbox but not the 2nd listbox. Furthermore, I really want to list not only the description for the value
3
7013
by: Jeff Ciaccio | last post by:
Man the help in VB.NET is hard to use!! Can somebody please tell me the syntax to find the index value a user has chosen from a list of items in a listbox. Also, is there a way to use the string value instead of the index number? I'm trying to do something like... if lstBox.items.index = 0 then stuff...
5
2680
by: ctj951 | last post by:
I have a very specific question about a language issue that I was hoping to get an answer to. If you allocate a structure that contains an array as a local variable inside a function and return that structure, is this valid? As shown in the code below I am allocating the structure in the function and then returning the structure. I know if the structure contained only simple types (int, float) this will work without problems as you...
7
2040
by: chanshaw | last post by:
Ok I'm looking to find the array index of the entered employee number here is my code #!/usr/bin/perl # Uses module Text::CSV # compiler directives use strict; use warnings; use Text::CSV;
0
9522
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
10111
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9765
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...
1
7327
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
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5215
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...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
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.