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




Select Item In DataList


This should be easy for you.
I have looked for this in the forum but haven't found any good answer.
Maybe a poor search, it should be present one would think.

I have a form consisting of a DataList that is populated by a recordset from an SQL query. (Not an Adodc, it's written in code).
When the form is shown I want the first item in the DataList to be selected.
How do I do that?

Cheers.

/Mats




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Easy One I Think.. How Do I Select An Item In A Datalist ?
There's an Item in a Datalist I want to be selected. How can I do that ?

Datalist Item Selection
If the user press a key of a letter (abcd...) the datalist selects the item that begins with that letter...... how can I disable this option in the datalist Object?

Thanks in advance for your help

Jose Reyes

DataList Selected Item Jumps To Top
Hey all,
I've got a silly little problem w/ a DataList I am using.
A user can select an item in the list but if they click anywhere else after that the item they selected moves it's self to the top of the datalist, leaving an unselected copy of its self below.

It's not really affecting my data per say but the order things appear in the DataList is fairly important due to th nature of the information.

Ideally I would like a way for that selectec item to stay where it is and stay selected.

Much thanks in advance

Ado 6 Access Selecting Item In Datalist Box
Hello.
I want to select an item in a datalist box and make this item appear back in a listbox. The datalist box is populated by use of a query. When the datalist item is put back into the listbox the database status will also need to change for that item.

I know when I'm using a listbox and want to select an item the coding is something like this
If listcar.listindex <> -1 then

but I'm not sure what coding to use with datalist boxes.

I am also told I will need to do an update and a requery.

I'm a bit clueless on this.

Thanks for any replies.


marsbarblue

Changing Selected Item In DataList Through Code?
I have a DataList control populated with an Adodc control, and I want to be able to select the first item in the list through code. Is there an easy way to do this? I found that moving in the ADO recordset doesn't affect which item is selected, and the .SelectedItem property which looked promising appears to be read only.


"Any fool can defend his or her mistakes; and most fools do." -- Dale Carnegie

DataList Multi-select
just discovered much to my dismay that the DataList does not have a MultiSelect property. I need to have the list directly connected to the database, so I can't very well use the old ListBox control since I am using ADO and would have to populate it on the fly.

can multi-select be done with a datalist? If so, how?

Auto-select First Record Of Datalist... HOW?
I tried to word this as best as I could, but you may have to read it twice. Thanks for any help.

I am trying to tackle how to automatically select the first record in a datalist. I want to set the boundtext of the datalist automatically when it loads rather than actually having to click on it. I am probably doing the same thing wrong here that I was earlier with some other stuff. Should I be trying to select the first record through manipulation of the recordset or rather try to select the first item of the datalist through direct manipulation of the datalist control? If so, how do I go about do that?

I currently am using a MonthView control to create a query by date that lists a number of records for that day in a datalist. Then, once I select a record in the datalist, another query is generated which a datagrid uses to display info about the particular item selected in the datalist.

The problem I am having is when I select a date, no particular record is selected from the datalist, and therefore, the datagrid displays information for ALL the records currently in the datalist. It works for me, but it sure confuses the heck out of the program's users and it looks unprofessional.

I hope someone can help me here.

Aminal

Select A Record Within A Populated Datalist
I have an app that when user selects a "Status" within a list box it populates a datalist of all the items in the the DB with that status. User than can then click on an item within the datalist which populates text boxes on the form with the details of the selected item. That all works great.


However, I need to be able to select the item in the Datalist (i.e. highlight it) from code. I am currently getting it to select the correct "Status" in the list box and fill the text boxes on the form, but the item is not selected in the datalist.

Does anyone have any ideas or links to some help?


Thanks.



Edited by - bear on 8/11/2005 6:40:01 AM

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

Get Datalist Selection To Correspond To Another Datalist
Hey,

I have two datalists on my form, both having a list of the exact same size. I would like it to highlight, or select, the appropriate item in one of them based on what was selected in the other datalist.

Using comboboxes, this is easy to do by saying:


Code:
combo1.ListIndex = Combo2.ListIndex

Is there a corresponding way to do this with datalists? Using the .SelectedItem property gets me the index value of what was selected in one of the lists, but how can I use this to with the second datalist?

Select Item In Combobox
Hello,

I'd like to select a value in a combobox. The combobox is filled wirh an array, the second column contains the search string.


Code:
l = Me.cmbGB1.ListCount
For i = 1 To l

If Me.cmbGB1.List(i, 1) = 8000 Then Me.cmbGB1.List(i, 1).Select

Next

Select All Item In ListView
Hi,

I just wondering if there is way to select all items in my list view.Let say I had 20 items in my list data,so how can I select all the items in one time.


Thanks.

How Do I Select The Last Item In A List?
I need to select the last item in a list no matter how big...how can I do this in a command click?

Select First Item In Listview
Hi,

I have a somewhat simple problem and I am wondering what the simplest way to handle it is. I have a treeview that I am loading with some information about files in a specific directory. The listview is set to automatically sort the list and after all the nodes are added, I want to have the top node in the treeview be selected. But I don't have a reference to the first node in the list. Are there any properties that I can use to get the node that is at the top of the list?

Thanks,
Jason O

Combobox Item Select
Hello, I have a combo box with 5 items on it, how can i display text pertaining to the select item in a text box when the user select's an item out of the combo box.

They click the wedge to drop down the 5 choices, and I want to be able to display information about their choice when they select it. I tried the change event, but that's only when you actually change the text of the box, I just want it to see when the text changes from Item1 to Item2. Is there any way of doing this without setting up a timer to constantly check the text in the box?

Thanks for any help. Appreciate it.

Select Item In ComboBox
How do I retrieve the "NAME" of the selected item in a combobox?
The selected item's Name will determine the items to be display in combobox2

How To De-select A List.item
If an item in a list has been selected, how do you de-select it?

Listview Select Item
In a listbox I select an item with: listbox.listindex = 0

I want to do the same thing with a listview.
I tried with: listview.SelectedItem = listview.ListItems(1)

But it does not work. Can anyone tell me what I'm doing wrong?

I Want To Select A Particular List Item
I have tried this

If frmItems.lstitems.listIndex = "Unknown"
frmItems.lstitems.RemoveItem frmItems.lstitems.ListIndex
End If

i want it to see if the item unkown is in the list of the listbox and then remove it

Item.key Problem In Sql Select
This is similar to my other post, but a little different code. Still can't get the error fixed, but i know the right id is being retrieved because it even says the correct id in the error. still keep getting a syntax error that says missing operator.

Dim rsIclick, SQL, intMediaId
Set rsIclick = New Recordset

SQL = "Select mediaid from media_tbl where " & _
"mediaid=" & Item.Key
Set rsIclick = conn.Execute(SQL)
intMediaId = rsIclick("MediaId")
MsgBox (rsIclick)

Select Item From MSHFlexGrid
I know that there are posts that come close to answering this question and I even got the code from the MakeDB Project which will help in other areas of the program. But what I need to do is have the user be able to click on an item in the populated recordset of an MSHFlexGrid and this action will populate the text boxes of another form.
The Idea is they bring up a form(form1) to edit items in the database. they are presented with a Select Item button that opens a form(form2) with the MSHFlexGrid on it that is populated with items in the database. They click the item, form2 is unloaded and form1 has all the fields filled in.

The grid is populated with the following code
Private Sub Form_Load()
Dim objrs As New Recordset
mySQL = "SELECT Description, Manufacturer, Category, Location FROM Items"
g_Conn.CursorLocation = adUseClient

objrs.Source = mySQL
Set objrs.ActiveConnection = g_Conn
objrs.Open
Set flexSelect.DataSource = objrs
DoInitialSettings
End Sub

g_Conn is an ADODB.connection made in a module at program startup


Any help will be appreciated.

Michael

Select A Item In Listview
hi,
i want to select a item in listview by code like this:
listview.ListItems(100).Selected =true
this work but if a have more than x items and if a donīt see the items that i selected the lisview donīt do the scroll down.
In a list1 control we have the listindex that can do the scroll down/up of the list, but in listview who we can do that?
thanks a lot for your help
bruno

Combo Item Select
VB Code:
Private Sub Combo1_Change()    MsgBox Combo1.TextEnd Sub


how come that doesnt msgbox anything when i select an item from the combo box?

ListView, Don't Want To Be Able To Select An Item
As the title says, I don't want to be able to select an item, I just want to list data, that's it.

I tried to unselect an item whenever i select one, but it still shows a doted rectangle around the selection.

This is the code I tried, but it does not really work.

VB Code:
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)    Item.Selected = FalseEnd Sub

Want To Select Item In TreeView
I have a treeView populated and upon an action I want a specific item to be highlighted in the TreeView, is that possible??

Select Item From TextBox
Hi Everyone,

I currently have a textbox with several email addresses in it separated by semi colons. How can I detect which addresses a user has selected and highlight that item only? Thanks for any help.

How To Select One Item Only In Listview
Hi,
To make sure only one item has it's checkbox 'checked' in a listview I run the following code in the 'item_check' event:

lvw.SelectedItem.Checked = True
lvw.SelectedItem.Bold = True
lvw.SelectedItem = lvw.ListItems(lvw.SelectedItem.Index)
lvw.SelectedItem.Bold = True

Which works fine. The problem is when the user clicks on the row rather than the checkbox itself. Doing this fires the 'click' event but the .selecteditem is now the row that has been selected rather the row it is coming from and I end up with two rows with their checkboxes checked.

I have tried to store the selecteditem before the click event fires but am not having much luck.

Please help!

De-Select A Listbox Item
How do you de-select a listbox item at design time?

How To Select An Item From A Listbox
I want the first Item of a listbox to be selected when a form loads.

Also, When I Select An Item In A Combo Box ...
... I want to be able to press an `OK` button what I also created and be able to access the page that is selected in the combo box.

I can`t find out how to do this because I just enter the combo names in the `List` property.

Any help on this one. Thanks.

Combobox Select Item
I want to select an item on a combobox list based on its listindex - i.e., from program code. I have created a newindex for each item based on its database key. Would someone tell me, please, how to do this?

Select Item In ListView By Value
Hi
I want to select an item in a ListView(Report Mode). I know the text but I dont know its index.

One way is to loop through it contents and select the index of my item. and then use

List.selectedItem=List.ListItems(Index_Obtained_in_Loop)

Is there any other direct way to slect the row of Listview, as we do for combobox or list box. Like, List.text="Value"

Select Item From A List Box
I have a list box that gets filled by account numbers read from a table.
Then details for the item that is selected from the listbox are displayed
accordingly.

My problem is, when I type the first few characters of an account number, it
should find a match in the listbox if a match is found, otherwise returns an
error message.

How can I do that? Please help..

Best regards,

Elizabeth Dumu
Business Solutions Section
BSP Information Technology Department

Phone: 3009 509
Fax: 3250 001
Email: email@removed



http://www.bsp.com.pg

How To Select A Particular Item In A Combobox
I want to pre-select an entry in a combo box when it loads. If there is an item with a journal description that contains "Recurring" I want the combobox to show that one instead of showing the first item. Can someone show me how to do this? Here is my code to load the combobox:

Sub loadCbo()
Dim i As Integer, n As String * 2, a As String * 4
cboJrnl.Clear
Set rs = db.OpenRecordset("SELECT * FROM GLJournals " & _
"WHERE coNum=" & comp, dbOpenSnapshot, dbReadOnly)
If rs.EOF Then Exit Sub
rs.MoveLast: rs.MoveFirst
For i = 0 To rs.RecordCount - 1
RSet n = rs!jnlNum
RSet a = rs!jnlAbbr
cboJrnl.AddItem n & " [" & a & "] " & _
rs!jnlDesc & Space(99) & rs!ID
rs.MoveNext
Next
If cboJrnl.ListCount > 0 Then cboJrnl.ListIndex = 0
End Sub

Select ComboBox Item
Hi, I'm using the ItemData properyt of a ComboBox control to save a product ID into a database field, when I want to load the info again I need to present to the user the item in the ComboBox that was saved before.

How can I do that. Note that I'm saving the ItemData of the Item into the Database.

Thanks in advance

Select Next List Item
I need to make it so that when command1 is clicked it makes the listbox selection go to the next one, but when command1 is first clicked it goes to the first listbox selection. thanks

Select Listview Item By Right Click
I have a listview and I would like the user to be able to select and item by right clicking it and also haveing a popupmenu. I have it so if they first left click on it then right click it would work, but I want to have it so they are able to just right click and have the menu apear. Here is the code that I have so far.

If Button = 2 Then
Dim aPt As POINTAPI
Dim anInd As Long
GetCursorPos aPt
With viewEntry
.SelectedItem.Index = LBItemFromPt(.hwnd, aPt.X, aPt.Y, False)
End With
PopupMenu DepClick
End If

This isn't working right because I tried to port it from a listbox. Any help would be great, thanks.

Right-Click Select Item In ListView
Hi. How can I program a ListView so that when the user right-clicks on it, the corresponding item is selected just as if the user had left-clicked? I thought of the SendMessage API but then how do I convert the X and Y values from the ListView's MouseDown event into an lParam value? i.e. how do i do the opposite of extracting High and Low-Order words?
Thanks in advance.

Select An Item In Combo Box Upon Load
Hi all,

I have a simple question. I have a VB6 program with at least 2 forms. The first form which interest us is used by a user to select the department in which he works. The second form receive that information plus the list of ALL departments.

What I want to acheive is this :

- The first form is opened.
- The user selects a departement from a combo box.
- The user clicks ok.
- The second form receive the information of the first form in a variable.
- Another combo box is present on the second form and is already filled with all the department names (identical to the one in the first form combo box).
- On load, the departement from the first form is selected in the combo box on the second form.

Is that clear enough to understand?

Select Menu Item On Another Program.
Hi there,
In my program, if I want to execute the click_event of a button on another program I just get its handle and send the "Enter" key. The problem is that I can not get the handle of the menu item so how can I execute the action under the menu item which I want to select?

Thanks a lot.

Select Item In File List Box?
How do you select an item by its list number in a File List Box at runtime using code?

Thanks

Select An Specific Item In ComboBox
How I do to select an specific item in ComboBox?
Thanks and good bye.

TreeView - Select Item Based On It's Key...
Hi Ya'll,

Is there any way to select an item in a treeview based on it's key property?
I really hope there is...

Thanks!

Greetz Kevin,

Do I Need To Use VirtualAllocEx To Select An Item From A Listview
Do i need to use VirtualAllocEx to select an item from a syslistview32 on an external program that is not in vb?

ListView And Select An Item URGENT!
First of all I do my apologize for my Eng.

I need to select an Item in a ListView20 control in another application.
I try to use the sendmessage with LVM_SETITEM and the constant LVIS_SELECTED + LVIS_FOCUSED in the LV.setmask (a part of structure)
but it doens't work.
I need a HELP urgently, it's very important for me to solve this probl. in a day or two!!!
Some suggestion???
Umberto

Select Combobox Item In External App
I get the hwnd of the combobox in question then execute this code:

Code:
If lngHwnd <> 0 Then
lngRetVal = SendMessage(lngHwnd , CB_FINDSTRINGEXACT, 0,objCust.Salutation)
If lngRetVal <> CB_ERR Then
lngRetVal = SendMessage(lngHwnd , CB_SETTOPINDEX, 0, lngRetVal)
Else
'I can't do anything about this I'm afraid.
End If
End If


The findstringexact message is returning index 4 which is correct for my combo, however the CB_SETTOPINDEX message does nothing???? What am I missing?

Cheers.

GoTo List Item And Select It
I have a list box with a bunch of dates in it. I also have a MonthView control. I'd like to click a date in the MonthView and have the listbox scroll to the first instance of that date in the list, and select it. I have no idea how to do it so my code isn't much but here it is:


Code:
Private Sub mntPickDate_DateClick(ByVal DateClicked As Date)
Dim intIndex As Integer

For intIndex = 0 To lstHistory.ListCount
If InStr(1, lstHistory.List(intIndex), Format(DateClicked, "mmmm dd, yyyy")) Then
Exit For 'change this to whatever will scroll to the item and select it
End If
Next intIndex
MsgBox "No activity was found for the date selected.", vbExclamation + vbOKOnly, "Date Not Found"
mntPickDate.Visible = False
End Sub

Auto Select Item In ListBox
A Form has a ListBox wherein only 1 item is visible at a time. Usually when a ListBox is scrolled using the mouse, the previous/next item becomes visible to him but the item that becomes visible DOESN'T get selected. The user has to click the item explicitly to select it (of course, if a user uses the keyboard to scroll the ListBox, the items get selected too but that's a different matter).

What I want is when a user scrolls the ListBox using his mouse, the item that becomes visible to him should automatically get selected as well.

Can this be accomplished? If yes, how?

Note that the ListBox doesn't include CheckBoxes.

Auto Select Item On Listbox
How do i auto select a item on a listbox ? like i mean if an item is already selected , on a timer i want it to go to the next item every 5000MS

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