Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Select Item In ListBox1 And Corresponding Item In ListBox2 Is Also Selected


Hi,
Hi I have two Listboxes list1 has lets say Firstname in List1 and List2 has surnames.
How do I select an item in List1 and have it's corresponding item in List2 selected as well?

So if I select Item 6 in List1, I want item6 in List2 to be selected too.

Ken




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Relate ListBox1 Item To ListBox2
I have 2 listboxes as so:


ListBox1

Don
Fred
Joe
Harry
Tom
Ed


ListBox2

A
B
C
D
E
F


If user clicks, say "Joe", in LB1, how can I save the contents of the corresponding line in LB2 ("C")so I can use it as a parameter in a search?
This will go in an Excel file. I also have Visual Studio Working Model.

Remove Dblclicked Item From ListBox1 & Add It To ListBox2
Hi everyone!

How shall I REMOVE the item I dblclickd from ListBox1 and have that item be ADDED to ListBox2?
I know this requires the Removeitem & Additem Method. I have been trying to figure it out but I can't get to it. The selected item is removed from ListBox1. However, instead adding the selected item to ListBox2, the first item in ListBox1 is the one added!?!?!?!
I am stuck on this... could anyone help?

Listbox2 Selected = Listbox1 Selected
I have 2 listboxes, List1 and List2 checkbox style. There's different data in each but the list count is the same for both. When an item is checked in List1 I want the same list index checked in List2.

List2.ListIndex = List1.ListIndex doesn't check the item in List2, it only highlights it.

Thanks

Select Field In Listbox1, Display Assoc. Records In Listbox2?
[using adodc in this project]

Hello,

I'm wondering does anyone know how to code the following:

Make a selection of a field from one list box1 (which is dynamically populated from the database) then in another listbox2 have the records associated with the field selection from listbox1 display in listbox2??

I can already populate listbox1 with fields from the database using:

Dim MyField As adodb.Field
    
    For Each MyField In frmenterdata.Adodc1.Recordset.Fields

        List3.AddItem MyField.Name

    Next

Now comes the tricky part of populating listbox2 with records from the field chosen in listbox1

Any help i can get would be appreciated, Thx

Making The First Combo Box Item Always The Selected Item
Hi.

I have a combo box with a Dropdown list Style and which is invoked several times in different parts of my form. How can I make the first item in this combo box the selected item or the default item everytime I select it? Currently, what's happening is that the last item that I selected becomes the selected item the next time the combo box is invoked. Thanks for any suggestions in advance!

Listbox1 To Listbox2
How would i move highlighted items in one listbox to the second with a button? im using VB2008 express.

Listbox1 And Listbox2
I'm trying to use listboxes for my newsletter and I'm stuck. Right now, I'm using listbox1 to hold all e-mails stored in the database. I'm using listbox2 to hold the selected e-mails from listbox1. If I highlight an e-mail in listbox1 and hit add, it should be stored in listbox2, but I'm not able to do that.

I was thinking about storing the database rows in a array so that I have an index and a value. From there I would populate the listbox1 to hold the e-mails so that when highlighted and add button is clicked, the e-mail would move to listbox2.

I'm not able to do that, does anyone have a good idea on how I could do this or go around it.

Listbox1 To Listbox2
how do i send the contents of List1 to List2?

for some reason i can't get it right.....

Wrap From ListBox1 To ListBox2
Plse help,
I am using MsAccess 2000. I have five list boxes. How do I get a large amount of data to fill list box 1 and the over flow to show in listbox 2 and lits box 3....

I tried several ways and don't seem to get anywhere.

Listbox1.height <> Listbox2.heght
I've got 2 listboxes sitting side by side on a form.

One has its style set to 0-Standard and the other 1-Checkbox.

Problem is that no matter what I do, in design time or run-time, I can't get their heights to be equal. Only way that'll happen is if I make them have the same style.

Am I missing something here?

I'm guessing that this is just the way it is but it makes the layout of my form look cheesy so I'd figured I ask.

Thanks

Copy From Listbox2 To Listbox1 With Command Button
I am trying to copy (or move) from listbox2 to listbox1, using simple multiselct, with a command button.

I want the command button to also remove the selected items in listbox2 after the selected items have already been copied to listbox1.

I got the copying part down, and it works. It's the list2.removeitem portion that is screwing me up. I can't figure out where and what to add exactly the list2.removeitem.
I left out the list2.removeitem in the code below.

Here is the code.

Any ideas?


Private Sub cmdmr_Click()
On Error Resume Next
Dim i As Integer
For i = 0 To List2.ListCount - 1
If List2.Selected(i) Then
List1.AddItem List2.List(i)
End If
Next i

End Sub

How To Search Listbox For Item If Item Not Found Add Item?
Hi, lol man I cant find nothing today when I search the forum.

This my latest problem, How do I search a listbox for an item lets say "Game Over" And if the item is found the program does nothing, but if the item is not found it will add "Game Over"

Thanks Again

Keeping Selected Item Selected (highlighted)
I have items selected in my listbox. My problem is that when i clcik on the file menu to delete them the highlight goes off them and the program thinks theres nothing to delete! How do i keep the highlight on the selected items and still click on other objects? Thanks

Keeping Selected Item Selected In A List Box
How could you keep the selected item selected until I refresh the list or till they unselect it?

Right now I have a global variable for the listIndex that is set on_mouse_down But I am not sure how to make the listIndex stay selected.

Selected Item
how do you change the color of the selected row of a listview. you know the normal color which is dark blue and its ugly. I want to use a light blue or tooltip color.

another question how do you find the total cpu usage of the system. or how do you find it for just 1 process ( its harder but i can add all the process cpus togethers )

Thanks!

Selected Item
Is there a way to select an item on the listview. Using the program of course not the persons mouse.

Such as...
Listview1.selectedItem = i
Because its not selecting it


Its actually replacing the first item and that cant happen in my prog

Selected Item
Hi All:
I am not sure how to accomplish this issue in VB. I have a listbox and it is populated with 5 items. I want to replace the text of the selected item from the listbox with the orgional text of the selected item+ "Del".

Something like this:
lstPerson.Selected(lstPerson.Listindex).Text =
lstPerson.Selected(lstPerson.Listindex).Text +"Del"

Please help!!
Thanks for all of you for helping me!!

Selected Item.
Hi,
I have got one question.

Dim selItemIndex As Integer

selItemIndex = Combo1.ListIndex
If selItemIndex = -1 Then
MsgBox "No item selected."
Else
Combo1.RemoveItem selItemIndex
End If

I am not sure What "-1" does in this program please?

Get Selected Item Name
Hi
For any windows form, desktop, can I get the selected item (Icon) name, like "doc1.doc", ....
Thanks in advance.

Keep Listview Selected Item Selected
I've been searching the site this morning and I've seen this question asked numerous times and the answer appears to be no. I thought I'd try again in case there is a fresh set of eyes out there.

I'm working on a preexisting production form and the person that designed it coded a series of combo boxes next to a series of listviews as user controls. When a combo box loses focus the selected item remains the default selected blue color. When the listview loses focus the selected item's color is a light gray.

I would like the listview selected item to remain blue like the combo boxes so the appearance is uniform.

The user community has lived with this for quite some time so I can't justify the time to rework the form. But if someone knows how to keep the selected item blue when the listview loses focus I'll plug it in though.

Listview Get Currently Selected Item
Is there a way to get the currently selecteditems text for a listview. I'm using vb 2005 and I don't see how to get a listview currently selecteditem. Someone please help me

Thanks for any help
Chris Ara

Listview Selected Item
How can i get the selected item of a listview in another form ???

I have tried with this code:


Code:
Public Function geselecteerdLid() As Integer
Dim iLidID As Integer
Dim oItem As ListViewItem
For Each oItem In lvwLeden.SelectedItems
iLidID = Convert.ToInt32(oItem.Text)
Return iLidID
Next
End Function
and in another form i refer to this with

Code:
Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
Dim oForm As New frmLid
MessageBox.Show(oForm.geselecteerdLid)
End Sub
the result of this is always 0, i guess this is because i make an object of the form where my listview is (frmLid)

If Item In A List Is Not Selected
Hi All,

How can I do a test to see if there has been any items in a list selected. ie. if there has not been an item selected show a message box, else form2.show.

Thanks

Loftty

Listbox Selected Item
Hello again!

I was wondering if anyone knew how to make the selected item from a listbox appear in a text box.

For instance List1 as the list box and Text1 as the text.box? Is it just one of the properties because I have not be able to find it.

Thank you for all your help!

Selected Item Or Subitem
I have a multi-column listview (report view).
If the user clicks on a SUBITEM (not item) , is it possible to know which subitem is clicked ?

or

to identify the user just clicked on ITEM or SubItem ?

thanks

Test To See If An Item Is Selected
i need to test if there is no item selected from the list of a listbox.
anybody know how?
thanks

Combobox Need To Have Item Selected
I have a combo Box and for it to go to next form I want an Item in the combobox to be selected but if nothing is selected then display an error below is my current code but it dosent work

Private Sub cmdAdd_Click()

Product = txtpCode.Text
If cmbColour.Text = "" Then
lblError.Caption = "Select a Colour"
Else
Colour = cmbColour.Text
End If

frmBasket.Show
frmShop.Hide

End Sub

Always Have Last Item In Listbox Selected
How can I make it so the last item in a listbox be selected, even after new items are added. For instance, lets say I had four items in a listbox like this:

I'm one
I'm two
I'm three
I'm four

At this point I'd want "I'm four" to be selected and if I added another item like this:

I'm one
I'm two
I'm three
I'm four
I'm five

Then at this point I would want "I'm five" to be selected. Does anyone know of a way to do this ?

Thanks in advance for any help!

How To Get Listview Selected Item?
Code:
Private Sub Form_Load()
With lvwSpecies
' Add three columns to the list - one for each data type.
' Note that the data type is set in the column header's
' tag in each case

.ColumnHeaders.Add(, , strHeader(0)).Tag = "STRING"
.ColumnHeaders.Add(, , strHeader(1)).Tag = "STRING"
.ColumnHeaders.Add(, , strHeader(2)).Tag = "String"
' Set the column alignment - has no bearing on the sorts.

.ColumnHeaders(1).Alignment = lvwColumnLeft
.ColumnHeaders(2).Alignment = lvwColumnCenter
.ColumnHeaders(3).Alignment = lvwColumnCenter

.ColumnHeaders(2).Width = 3000
'Populate the list with data in Species files
Dim intCounter As Integer
With .ListItems
For intCounter = LBound(codeTypeArray) To UBound(codeTypeArray)
With .Add(, , codeTypeArray(intCounter).strCode)
.ListSubItems.Add , , codeTypeArray(intCounter).strCodeInfo
.ListSubItems.Add , , str(codeTypeArray(intCounter).intMaxNumber)
End With
Next
End With
End With

End Sub




Private Sub ok_Click()
Dim str As String
str = lvwSpecies.text

'what should go here if i want to get the text of select item? i just
'need the text of first colum.


End Sub
Is there a way to get the item text?
Thanks

Selected Item In A Listbox
how do i find the selected item in a listbox???

Listview - Selected Item
Dear All,

I have an access DB connected to a Treeview and a listview.

Navigation is done by ADO unbound.

How do I connect the highlighted item in the listview with a particular database recordset?


Say for example:

I click on the Next_Record button I would like the Cursor (Highlighted blue area) to move to the next record displayed in the listview corresponding to the correct database record.

Prev_Record button will move the blue highlighted area one position up in the listview and so forth...

Any ideas?

TIA

DHTMLEdit Set/Get Selected Item
Hi

I found the DHTMLEdit control just a few days ago, and it is really a good solution for my problems. Now I don't need to write a whole texteditor with images support, like I already started.

However, I need to know a few things about, it. The best way would be a nice tutorial on how to use it, or a good documentation (MSDN isn't that pretty good). Or some example applications. :/

Here are my questions, maybe someone knows some answers:
-------------------------------------------------
1) How can I find out, the selected object? (images, i.e.)

I tried the solution from the MSDN, but I can't define the following variable:
Dim ctlRg As IHTMLControlRange

Visual Basic don't know what a "IHTMLControlRange" is o.o
-------------------------------------------------
2) How can I SET the current selected object? (images, i.e.)
-------------------------------------------------
3) How can I select the last inserted image, immediately, after I inserted it?


Thanks for every help =D

To Put The Value Selected Item Into Variable
hi guys, i have use listview to display information of employee's application, whut i want is when user click on the specific date on list view it will open the other form and the info abt the application displayed is application on the date user click on. But it cannot display because there is an error. Below is my code




Code:




Option Explicit

'Declaration to change form
Const LWA_COLORKEY = &H1
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Const BM_SETSTATE = &HF3

Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

Private Sub Form_Load()

'Window according to picture
Dim lngSTL As Long
Dim lngCLR As Long

lngCLR = RGB(0, 255, 0) 'this color is the color that will be transparent
'Set the window style to 'Layered'
lngSTL = WS_EX_LAYERED
SetWindowLong Me.hWnd, GWL_EXSTYLE, lngSTL
SetLayeredWindowAttributes Me.hWnd, lngCLR, 0, LWA_COLORKEY

sqlStr = "select Emp.FullName, LApp.EmpNo, LApp.Date_app, LApp.LCode, MLiv.LName"
sqlStr = sqlStr & " from tblMEmployee Emp, tblLeaveApp LApp, tblMLeave MLiv"
sqlStr = sqlStr & " Where Emp.EmpNo = LApp.EmpNo"
sqlStr = sqlStr & " and LApp.LCode = MLiv.LCode"
sqlStr = sqlStr & " and LApp.RecStatus = 'Waiting'"
sqlStr = sqlStr & " and LApp.RecEmpNo = '" & ndEmpNo & "'"
sqlStr = sqlStr & " and LApp.ApprStatus IS NULL "
sqlStr = sqlStr & " Order By LApp.Date_app, Emp.FullName"

myRecSet.Open sqlStr, MyConnObj, adOpenKeyset

Dim itmX As ListItem ' Create a variable to add ListItem objects.
Dim clmX As ColumnHeader ' Create an object variable for the ColumnHeader object.
' Add ColumnHeaders.
Set clmX = ListView1.ColumnHeaders.Add(, , "Date Apply", ListView1.Width / 6)
Set clmX = ListView1.ColumnHeaders.Add(, , "Name ", ListView1.Width / 3)
Set clmX = ListView1.ColumnHeaders.Add(, , "Leave Type", ListView1.Width / 3)
Set clmX = ListView1.ColumnHeaders.Add(, , "Leave Code", ListView1.Width / 25)
Set clmX = ListView1.ColumnHeaders.Add(, , "EmpNo", ListView1.Width / 25)
Set clmX = ListView1.ColumnHeaders.Add(, , "Date_app", ListView1.Width / 25)

ListView1.BorderStyle = ccFixedSingle ' Set BorderStyle property.
ListView1.View = lvwReport ' Set View property to Report.

Dim ndDate, ndFDate As String

Do While Not myRecSet.EOF '''

ndDate = myRecSet("Date_app")

ndFDate = Mid(ndDate, 7, 2) & "-" & Mid(ndDate, 5, 2) & "-" & Mid(ndDate, 1, 4)

' Add a main item
Set itmX = ListView1.ListItems.Add(, , ndFDate)'-->i want to get this value
' Add two subitems for that item

itmX.SubItems(1) = myRecSet("Fullname")
itmX.SubItems(2) = myRecSet("LName")
itmX.SubItems(3) = myRecSet("LCode")
itmX.SubItems(4) = myRecSet("EmpNo")
itmX.SubItems(5) = ndDate

myRecSet.MoveNext

Loop

myRecSet.Close


End Sub

Private Sub Form_Unload(Cancel As Integer)
Form6.Show
End Sub

Private Sub ListView1_DblClick()


ndLeaApprEmpNo = Trim(ListView1.SelectedItem.SubItems(4))
ndLeaApprLCode = Trim(ListView1.SelectedItem.SubItems(1))
ndLeaApprDt = Trim(ListView1.SelectedItem.SubItems(5))
'MsgBox ndLeaApprEmpNo & ", " & ndLeaApprLCode & ", " & ndLeaApprDt
ndLeaApplydt = Trim(ListView1.SelectedItem.Items)'-->this is the code where i try to get main item value but it said method or data member not found
Unload Me
formSignature.Show

End Sub






can anyone help me fix my code

Selected Item Of Combobox
In VB 2005 it is cboServer.SelectedItem, but how can I find he selected item of an combobox in vb 6.0 ?

Listview: Has Any Item Been Selected?
In a listview, how do I know whether any item has been selected? ListView.SelectedItem returns a number even if no line has been clicked on.

Retrieve The Selected Item Name
Can anyone please tell me how to retrieve the NAME of an item selected in a LISTBOX?

For e.g. a user has entered 3 names (x, y and z) into the list box . How can I retrieve the selected name?


Thanks alot

Item Selected In Treeview
Hi,

is there a way to test if there's at least 1 item selected in my treeview?

TIA

ListView Selected Item!
In a WebBrowser project, a ListView acts as the history window. This ListView comes up when the History button is clicked. Each URL is represented in the ListView by the title of that URL (like IE). For e.g. if the user has visited http://www.yahoo.com, it's title i.e. Yahoo! will get listed in the history ListView. Users have been given the option to delete any URL/s from the ListView.

Assume that currently I am viewing http://www.yahoo.com. If the history ListView is now invoked, Yahoo! will be highlighted in the ListView (since I am presently viewing http://www.yahoo.com). Suppose I delete any other URL in the ListView. Under such circumstances, the very first URL gets highlighted in the ListView but I want Yahoo! to remain highlighted in the ListView after that URL is deleted from. How do I accomplish this?

ListView Selected Item!
In a WebBrowser project, I am using a ListView which acts as a "history" window (like how IE opens a side-window when the history icon is clicked on the toolbar). As is evident, the ListView lists all the URLs that a user has visited.

When I click an item in the ListView, I want that after the appropriate web page gets downloaded completely, the item selected should remain highlighted which is why I have set the ListView's HideSelection property to False.

Assume that I click the 5th item in the ListView. When I do so, the selected URL gets highlighted & the browser navigates to the corresponding URL but after the web page gets downloaded completely, the first item in the ListView gets highlighted but I want the item that was clicked by the user should remain highlighted after the web page loads completely. In other words, I want the 5th item in the ListView to remain highlighted after the web page loads (since I had clicked the 5th item in the ListView). How do I implement this?

Whenever the ListView loads, the first item in the ListView is seen highlighted (as HideSelection is set to False) but I don't want the 1st item (or for that matter, any of the items) in the ListView to get highlighted whenever the ListView loads i.e. none of the items should be highlighted whenever the ListView loads. How do I do this?

Listview Selected Item
ok my app has a listview which has a check box in it. I have setup so that when someone clicks on an item, the selected item becomes checked. how do i set for when the item becomes checked, the item becomes selected???

hope i explained that correctly...


please help me code

Listview Selected Item
I have a listview on a form...
The item which is selected should be selected even if the form looses focus or unloads.
Next time when form gets focus that previously seleted item should be selected...........

First Selected Item In Treeview
I have a little program tha thas a treeview in it. by default when the program opens up nothing is selected. but if you click any where in the box it selects the very fisrt item (the parent)

how do I set it so you don't have to click on the box or anywhere to get the first item to be selected?

If Item In A List Is Not Selected
Hi All,

How can I do a test to see if there has been any items in a list selected. ie. if there has not been an item selected show a message box, else form2.show.

Thanks

Loftty

Remove Selected Item
how do i remove the selected item from a listbox?

thanks d00dz.

ListView Selected Item
Have any easy question about ListViews. When my form opens up the first item in my listview is selected. How would I keep this from happening? Do I need to loop through all items in the list view and set the selected property to false or is there an eaiser way. I would like to keep my load time down on my form.

Thanks ahead of time.

Listview Selected Item
Hi,

I have a listview populated with a few dozen records from my database.
The listview has 10 column's. I try to make a change to for example the 3th record the 5th column. Althougt I select the 5th column always the first column of the 3th record is updatable.
How can I accomplish that I can select any cell of the listview to make an adjustment with I can send to my database.

I'm in great need for a solution, but can't (after a whole try and search) find it, plaese has someone a helping hand

With regard, thanx in advance

Charles

Which Item Selected In Imagecombo ? **
How do I tell which image the user has selected in an imagecombo control in which there are just images (no text)


VB Code:
Option Explicit Private Sub Form_Load()     Dim sColourArray(9) As String, i As Integer        sColourArray(0) = vbBlue    sColourArray(1) = vbRed    sColourArray(2) = vbGreen    sColourArray(3) = vbYellow    sColourArray(4) = vbBlack    sColourArray(5) = vbWhite    sColourArray(6) = vbCyan    sColourArray(7) = vbMagenta    sColourArray(8) = vbButtonFace    sColourArray(8) = vbHighlight    sColourArray(9) = vbInfoBackground        For i = 0 To 9        picPicBox.BackColor = sColourArray(i)        ilsImageList.ListImages.Add , , picPicBox.Image                icmbColourCombo.ComboItems.Add , , , i + 1    Next End Sub Private Sub icmbColourCombo_Click()     'What goes here ? End Sub

Which Item Selected In Combo Box
hello, how do I determine which item was elected in a combo box. I'm trying to use that info to make a selection in another combo box. Ex. If the user selects REG in the first combo box then 38 is shown in the next box. Here is my code so far. Do I need to create a variable and also use the index number?

Private Sub cboCTypeHrs_GotFocus()
If cboCTypeHrs.ListIndex = 0 Then
cboComRate.Text = 38.4
ElseIf cboCTypeHrs.ListIndex = 1 Then
cboComRate.Text = 57.6
Else: MsgBox ("Which rate should be used for hourly rate?")
End If
End Sub

As you can see, the first time I tab to it(cboCTypeHrs) I get the message box, if I choose Reg and tab to it again the 38.4 shows up in the other box, but I can never get OT to show 57.6 in the second box.

thanks, jim g

How Do You Get A Selected Listbox Item's Name?
i have a question. how do you get a selected listbox item's name? what i mean is if i selected "yo" from my listbox i want text 1 to be yo when i click a command button or something. plz help. thanks in advance

Copyright © 2005-08 www.BigResource.com, All rights reserved