I want to open a window with a listbox (custlist) in it, but I want to
automatically select a certain item in the listbox, and have it be the
correct selectedindex. The call to open this window knows what it seeks,
which is variable. So one time I may wish to select item 45 (marsdon) and
sometimes item 1997 (albert). How can I do this?
Thanks for any help.
Bernie Yaeger 2 1342
August 7, 2004
You can use custlist.Select edIndex = index or
custlist.Select edItem =
String. The following is an example of selecting a item based on a
random
number. The listbox1.items are: Test1, Test2, Test3, ..., Test6.
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Randomize()
Dim r As Integer
r = Int(Rnd() * 5)
Label1.Text = r 'Displays number for testing purposes
ListBox1.Select edItem = "Test" & r ' OR
Listbox1.Select edIndex = r - 1 ' - 1 because of zero based array
End Sub
These methods work fine for your purpose. Have a nice day!
Joseph MCP
"Bernie Yaeger" wrote: I want to open a window with a listbox (custlist) in it, but I want to automatically select a certain item in the listbox, and have it be the correct selectedindex. The call to open this window knows what it seeks, which is variable. So one time I may wish to select item 45 (marsdon) and sometimes item 1997 (albert). How can I do this?
Thanks for any help.
Bernie Yaeger
Hi Joe,
I actually found another way of getting this done, but tx - you suggestion
worked fine as well!
Thanks again,
Bernie
"Joseph MCP" <Jo*******@disc ussions.microso ft.com> wrote in message
news:10******** *************** ***********@mic rosoft.com... August 7, 2004
You can use custlist.Select edIndex = index or custlist.Select edItem = String. The following is an example of selecting a item based on a random number. The listbox1.items are: Test1, Test2, Test3, ..., Test6.
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Randomize() Dim r As Integer r = Int(Rnd() * 5) Label1.Text = r 'Displays number for testing purposes ListBox1.Select edItem = "Test" & r ' OR Listbox1.Select edIndex = r - 1 ' - 1 because of zero based array End Sub
These methods work fine for your purpose. Have a nice day!
Joseph MCP
"Bernie Yaeger" wrote:
I want to open a window with a listbox (custlist) in it, but I want to automatically select a certain item in the listbox, and have it be the correct selectedindex. The call to open this window knows what it
seeks, which is variable. So one time I may wish to select item 45 (marsdon)
and sometimes item 1997 (albert). How can I do this?
Thanks for any help.
Bernie Yaeger This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: (Pete Cresswell) |
last post by:
Seems like I've been here before, but can't find anyting in Google.
I've got two list boxes on a form.
Seems to me like the inactive ListBox's selection rectangle should be something
like gray...otherwise, the user sees two ListBoxes, both with black selection
rectangles - and the user does not visually know which one he is "in". This
becomes relevant if we have a keyboard-type user - they want to hit "Enter" and
have something...
|
by: Dan Bass |
last post by:
If you look at explorer, right clicking on a file, first selects the file,
then throws up the context menu relating to that selection.
With a Windows ListBox control and a simple context menu, the default
behaviour seems to display the context menu on the listbox, but there is no
selection.
Now I know that explorer's using a listview, and that the context menu acts
differently if you click on open space (no selection), but can I...
|
by: Alpha |
last post by:
I have a listbox with datasource from a dataview. When a user selects a
different item in a combobox then I need to refresh the listbox to the
appropriate listing based on that combobox's selected value which is included
in the listbox's filtering statement.
Is the only way to do this is to dispose the dataview and then create a new
one and then bind it to the listbox? Is there a better way than this?
Thanks, Alpha
|
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)..
...
|
by: Lie |
last post by:
Hi all,
I have problem in getting selectedindex of multiple listbox selection in a
datagrid. I have a listbox with multiple selection mode inside datagrid. In
Edit mode, I need to get back all selected items of that listbox and display
it.
can anyone help?
Thanks
| |
by: Paul |
last post by:
Hi I have a listbox and have the selection mode set to multiple in the
property box.
I am trying to set multiple selected values in code but it only seems to use
the last one.
listbox.SelectedValue = 1
listbox.SelectedValue = 2
thanks.
only 2 gets set above.
--
Paul G
|
by: Guy Noir |
last post by:
OK. I need help.
I have a listbox, a combo box and some text fields
The list box is populated by a dataSet
The comboBox is populated by a dataSet
When an entry is selected in the listbox, I would like the comboBox to
move to a particular entry based on the listbox selection.
|
by: Sanjin |
last post by:
I have populated listbox with data from the datatable.
I binded SelectedValue to the another datatable - i.e. selection result
(with VS 20005 wizard).
Selection result datatable has one column with type Int32.
|
by: zdrakec |
last post by:
Hello all:
Clearly, I'm not getting it! Here is the scenario:
On a web page, I have two list boxen and a text box. The first listbox
is populated at page load time (if it is not a postback). This listbox
has AutoPostback = True. When the user selects an item from this list,
the second listbox is populated with more items relevant to this
selection. I am using an SQLDataSource web control for this. These
items are headers. I want, when...
|
by: kimiraikkonen |
last post by:
Hi,
I have a odd but a known question about listbox. I know listbox
control can provide multi-select, multi-extendend selections. But i
wonder if this selection type belongs to them or it has another
tecnique.
As you may know, in softwares like Windows Media Player or Winamp
playlist has a listbox and it can be selected in 2 types. First type
refers to player's own selection and second selection type can be done
by user to look for...
|
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...
| |
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...
|
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,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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: 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...
| |