ListView Selecting An Item
Dear friends
I'm using ListView control, but I'm having problems to select/focus an datermined cell in the grid. For example, I click in the second cell in the third line, nut thw focus alway happen to the first cell of the third line. How I do to select/focus the cell that the user clicks? Thanks and sorry about my bad english.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Selecting An Item From A ListView
Here is what MSDN says to do to select an item from a listview:
"
To programmatically select a ListItem object, use the Set statement with the SelectedItem property, as follows:
Set ListView1.SelectedItem = ListView1.ListItems(1)
"
I cannot seem to get it to work. Is there a property that I need to set or I have set wrong?
Here is a simple example that I am trying to get to work without any luck:
Private Sub Command1_Click()
Set lstView1.SelectedItem = lstView1.ListItems(1)
End Sub
I cannot get this to do anything.
Any ideas??
Automatically Selecting An Item In ListView VB6
I've just changed over a set of information I had from a tabbed listbox to a listview because of it's ease of resizing use etc. However - I need to be able to automatically highlight an item in the list from the code. I used to be able to do this in the listbox just by the Obj.ListIndex = [number] syntax - but I can't find the property to do it. Here's what I'm doing to clear all of the selected ones in the ListView and then setting the one I want :
Public Sub SelectItem(Item As Integer)
If Item < -1 Then Item = -1
If DiaryList.ListItems.Count <> 0 Then
For a = 1 To DiaryList.ListItems.Count
DiaryList.ListItems(a).Selected = False
Next a
If Item <> -1 Then DiaryList.ListItems(Item).Selected = True
End If
End Sub
Obviously what i'm doing here is if I want to clear all Items from being Selected I call the Sub with -1 - however if I call it with an integer - I want it to clear all the others and highlight THAT item. This sets the properties right - I've checked in the Watch - but unfortunately does not show the item as being highlighted/selected in the on screen ListView. I've even tried calling DiaryList.Refresh at the end of the sub to no avail.
Any ideas?
Thanks
Adam Hourigan
Problem Selecting First Item Of External Listview
Hi all i got this code that supposed to select and highlight the first item of external list view but unfortuntly when i click the command button it does not do any thing. It seems it can not find the right window . i placed the class name of external listview and caption of the window that holds the listview but no luck. i be happy if an expert tell me how to fix this.Thanks
Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Type LV_ITEM
mask As Long
iItem As Long
iSubitem As Long
state As Long
stateMask As Long
pszText As String
cchTextMax As Long
iImage As Long
lParam As Long
iIndent As Long
End Type
Private Const LVM_FIRST = &H1000&
Private Const LVM_SETITEMSTATE = (LVM_FIRST + 43)
Private Const LVIF_STATE = &H8&
Private Const LVIS_FOCUSED = &H1
Private Const LVIS_SELECTED = &H2&
Private Const PROCESS_VM_OPERATION = &H8
Private Const PROCESS_VM_READ = &H10
Private Const PROCESS_VM_WRITE = &H20
Private Const PAGE_READWRITE = &H4&
Private Const MEM_RESERVE = &H2000
Private Const MEM_COMMIT = &H1000
Private Const MEM_RELEASE = &H8000
Private hWndlvw As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As String) As Long
Dim strCaption As String
Dim lLen As Long
hWndlvw = FindWindowEx(hWnd, 0&, "SysListView32", "")
' If we've found a window with the SysListView32 class
' check to see if parent window caption is the one we are looking for
If hWndlvw <> 0 Then
lLen = GetWindowTextLength(hWnd)
If lLen > 0 Then
strCaption = Space(lLen)
GetWindowText hWnd, strCaption, lLen + 1
End If
End If
EnumWindowsProc = (hWndlvw = 0 And strCaption <> lParam)
End Function
' New example looks for a window with class SysListView32 that is hosted
' by a window whose caption matches the contents of strInWindowWithCaption
Public Function FindListView(strInWindowWithCaption As String) As Long
EnumWindows AddressOf EnumWindowsProc, StrPtr(strInWindowWithCaption)
FindListView = hWndlvw
End Function
Public Function MessageCrossProcess(ByVal hWnd As Long)
Dim lProcID As Long
Dim hProc As Long
Dim lxprocLVITEM As Long
Dim LVITEM As LV_ITEM
Dim lItemPos As Long
GetWindowThreadProcessId hWnd, lProcID ' Get the process ID in which the ListView is running
If lProcID <> 0 Then
hProc = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, lProcID) ' make sure we have read write permissions in the process space
If hProc <> 0 Then
lxprocLVITEM = VirtualAllocEx(hProc, 0, LenB(LVITEM), MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE) ' Grab enough memory in the other procedure's space to hold our LV_ITEM
' Set up our local LV_ITEM to change the selected item
LVITEM.mask = LVIF_STATE
LVITEM.state = True
LVITEM.stateMask = LVIS_SELECTED Or LVIS_FOCUSED ' Just enforcing the selection better than in original version by moving the focus as well
' Copy the local LV_ITEM into the space we reserved in the foreign process
WriteProcessMemory hProc, ByVal lxprocLVITEM, ByVal VarPtr(LVITEM), LenB(LVITEM), 0
' Now send the message, but pass the address of the copy of our LV_ITEM that now exists in the foreign process instead of our local version
lItemPos = 0& ' first item
SendMessage hWnd, LVM_SETITEMSTATE, lItemPos, ByVal lxprocLVITEM
' Clean up
VirtualFreeEx hProc, ByVal lxprocLVITEM, LenB(LVITEM), MEM_RELEASE
CloseHandle hProc
End If
End If
End Function
and the on click event
Code:
Private Sub Command1_Click()
MessageCrossProcess FindListView("Rooms List - Search Results")
End Sub
ListView: Selecting Item Baised On .text
with the ListView, report mode
I want to do
VB Code:
listview.listitem(x).selected= true
based on a certain item.text string
is there a way to specify the item index using the string text?
I know what all the texts will be, but not the order.
(or do I have to scan all item's text for a match? yawn!)
ListView - Selecting First Item In List Causes Rename
I have an application with several Listview controls on it, in report view containing a few columns of data.
The application requires selecting some items in the ListView and adding them to another Listview.
My problem is that when the first item in the ListView is selected (only for the first item) It tries to let you rename the item, rather than merely selecting it.
Does anyone know if there is a way to stop this from happening?????
Single Item List Box (item Not Really Selecting)
Application=Access2002
The following code has worked for me in the past but won't now for some reason.
I have a private function and/or subs that performs a few simple operations such as setting listbox rowsources and simple math functions on a form. The queries set as rowsource use criteria from other single item listboxes.
Now, for some reason, the queries won't return values until the previously .selected(0) = true (single item) list boxes have been clicked on.
Problem has only been in creating a new form. Perhaps the problem did not occur in older created forms due to compatibility?
Private Sub fraEWTo_AfterUpdate()
[Edited]
lstRotorHoursPriorTo.RowSource = "qryRotorSwapHoursTotTo" 'gets hoursprior from tblRotors
lstRotorHoursPriorTo.Selected(0) = True ' This is one place where the problem seems to exist, the control does not function until it has been clicked on via mouse.
LstClockInTo.RowSource = "qryRotorSwapRAHoursIPTo"
LstClockInTo.Selected(0) = True
txtRACHIPTo.Locked = False
txtRACHIPTo.Value = txtClockHoursTo.Value - lstClockInTo.Value 'nor will this until the lstClockInTo box has been manually selected
A Mechanic in a Programmers shoes
Thanks
Edited by - greenfch on 12/7/2005 11:22:52 AM
Click Item In Listview Then Show That Item In Combo As Index = 0
Hi guys,
I have a listview (lvwUserPunchedOut) that is populated with records in a database (persons first name in one column and last name in the second column), what I am looking to do is if I select a persons name by clicking on it in the listview on frmMain, and then bring up frmSearchCriteria, i would like to show that selected name in the combobox as default (cboEmployee.ListIndex = 0) on frmSearchCriteria (the combobox is sorted = True and is also populated with first name and last name of the person)
How would this be done? Hope I make sense. Thanks in advance.
2 ListView Questions. 1 About Selecting Records. 2 About Adjusting Listview Box Size.
Hi,
I'm changing some of my programs to use a ListView instead of a ListBox.
1. On selecting a record how do I pass the info from the fifth column to another Sub? (I have .FullRowSelect = True)
2. I'm dynamically adjusting the column widths to the maximum length of the data going into the column. Is there a way to dynamically adjust the width of the listview box itself to be the sum of the column widths?
Thanks,
Al.
Selecting An Item In A Listbox
I was using this following code to select the item in the combobox I needed but now I need to just be able to specify the ID of the number and it select it in the combobox. Can anyone shed some light?
Code:
Sub LoadBillToList(ItemName, ItemID)
If ItemID = "" Then
ItemID = 0
End If
frmInvoices.txt_BillToID.Clear
If strDBOpen = 0 Then
OpenDatabase
End If
strSql = "SELECT ID, CompanyName "
strSql = strSql & "FROM BillTo "
strSql = strSql & "ORDER BY CompanyName asc"
Set rs = my_Conn.Execute(strSql)
If rs.EOF Or rs.BOF Then
Else
frmInvoices.txt_BillToID.AddItem ItemName
frmInvoices.txt_BillToID.ItemData(frmInvoices.txt_BillToID.NewIndex) = ItemID
strTempI = 2
Do Until rs.EOF Or rs.BOF
strBillID = rs("ID")
frmInvoices.txt_BillToID.AddItem rs("CompanyName")
frmInvoices.txt_BillToID.ItemData(frmInvoices.txt_BillToID.NewIndex) = rs("ID")
rs.MoveNext
strTempI = strTempI + 1
Loop
End If
rs.Close
Set rs = Nothing
CloseDatabase
End Sub
Selecting An Item In A Text-box....
I hate to continue to bug, but I can't seem to figure out how to select an "item" in a list-box and have it perform an action (just by selecting it.)
I'm trying to display some info (a caption) that will change according to which list-box item is highlighted/selected.
I'm also needing to be able to delete the highlighted/selected item from the list and my .dat file when I press a "Delete" button...
Thanks.
Selecting Item From A Listbox
Hi, I could never figure this out. How do i select something from a listbox and make it do something. I have a listbox with user accounts for my game. and i dunno what command i would use to select it. because. i cant assign any items with an itemdata because its consistently changing with autoupdated accounts etc. and with Inventory Items etc... Is there any way to select a listbox item without any Assigned Itemdata?? if so.. Can N e 1 help me? Thanks. I have tried pretty much everything i can think of. Thanks.
Selecting Last Item In Listbox
I have an Access form that has an Access ListBox. When adding items to the listbox via form controls (Access ComboBoxes, etc), the VBA will do the .ReQuery method of the Access ListBox. When that happens, the ListBox's scrollbar stays in the same place in the list (i.e doesn't move.) Is there a way to use the SendMessage API or another API call to move the scrollbar to the bottom of the list after my app runs the .Requery method? I want this so that the users can always see the last items entered into the ListBox.
Selecting A Menu Item
I've been trying for a few days now to select a menu item using API. I just can't do it. I've tried to send the WM_COMMAND, WM_MENUSELECT, and various others but to no avail... can someone give me a good description of how to do this? I know my code works as far as finding the proper submenu handle and menu item ID, but from there I don't know how to send a message that will select that menu item like a mouse click would normally do. Thanks very much!
Selecting A List Item
I have a listbox and it is labeled A-Z. isit possible to have it where when the application starts it automaticly picks Z?
Selecting A Item From A ComboBox
Hi,
I have a form which allows users to enter details and save them to a table in a access database. Users use a mix of text boxes and ComboBoxes to enter the required data.
I have comboboxes which pull data from two lookup tables and insert the ID of their selection in the table which is great.
The problem comes when I come back to this form to view the entered data.
Both the ComboBoxes are empty. How can I get the ComboBoxes to set their default value to match that of their corresponding value in the table.
Heres my code so far:
Quote:
Private Sub Form_Activate()
'On Error GoTo errHandler
Dim sSql As String
Dim adoRSA As ADODB.Recordset
Dim adoField As ADODB.Field
Dim lCol As Long
Dim lRow As Long
Dim lWidth As Long
Dim labEntry As Label
Dim txtEntry As TextBox
Dim vArr As Variant
Dim lX As Long
Dim sHide As String
If Me.Tag = "loaded" Then Exit Sub
Me.Tag = "loaded"
Me.Icon = frmAccount.Icon
'txtEdit.Visible = False
'load IP details
sSql = "SELECT IPdetails.* " & _
"FROM IPdetails WHERE Clis = " & glCli
Set adoRS1 = gadoConnDB.Execute(sSql)
If Not adoRS1.EOF Then
'If adoRS1(tickProgrammed.DataField) Then
'tickProgrammed.Value = 1
'Else
'tickProgrammed.Value = 0
'End If
For Each txtEntry In txtIPDetails
txtEntry.Text = adoRS1(txtEntry.DataField)
'If tickProgrammed.Value Then
'txtEntry.BackColor = &H8080FF
'Else
'txtEntry.BackColor = &H80000005
'End If
Next
'framePBX.Tag = .TextMatrix(.Row, 2) 'save lCli
Else
For Each txtEntry In txtIPDetails
txtEntry.Text = ""
txtEntry.BackColor = &H80000005
Next
'tickProgrammed.Value = 0
'framePBX.Tag = .TextMatrix(.Row, 2) 'save lCli
End If
Dim strSQL As String 'Declare the variables we need
'Load the data
'** change this SQL to load the data you want.
strSQL = "SELECT * FROM PackageType"
'** change oConn to the name of your Connection object
Set adoRScombo1 = gadoConnDB.Execute(strSQL)
'Fill the combo box (or ListBox)
'** change the name of the combo to the one you want to fill
With CboPackageType
.Clear
'Do While Not adoRScombo1.EOF
'** change the name of the field here to the one you want to show
'.AddItem adoRScombo1.Fields("Package").Value
'adoRScombo1.MoveNext
Do Until adoRScombo1.EOF
CboPackageType.AddItem adoRScombo1.Fields("Package").Value & ""
CboPackageType.ItemData(CboPackageType.NewIndex) = adoRScombo1.Fields("PackageId").Value
adoRScombo1.MoveNext
Loop
'If CStr(CboPackageType.ItemData(CboPackageType.NewIndex)) = CStr(adoRS1("Package")) Then
'CboPackageType = True
'Else
'End If
End With
'Tidy up
adoRScombo1.Close
Set adoRScombo1 = Nothing
Dim strSQL2 As String 'Declare the variables we need
'Load the data
'** change this SQL to load the data you want.
strSQL2 = "SELECT * FROM ProviderName"
'** change oConn to the name of your Connection object
Set adoRScombo2 = gadoConnDB.Execute(strSQL2)
'Fill the combo box (or ListBox)
'** change the name of the combo to the one you want to fill
With CboProviderType
.Clear
'Do While Not adoRScombo2.EOF
'** change the name of the field here to the one you want to show
'.AddItem adoRScombo2.Fields("Provider").Value
'adoRScombo2.MoveNext
Do Until adoRScombo2.EOF
CboProviderType.AddItem adoRScombo2.Fields("Provider").Value & ""
CboProviderType.ItemData(CboProviderType.NewIndex) = adoRScombo2.Fields("ProviderId").Value
adoRScombo2.MoveNext
Loop
End With
'Tidy up
adoRScombo2.Close
Set adoRScombo2 = Nothing
End Sub
Private Sub cmdUpdateContact_Click()
Dim sSql As String
Dim adoRS1 As New ADODB.Recordset
Dim txtEntry As TextBox
'update ip data
sSql = "SELECT IPdetails.* " & _
"FROM IPdetails WHERE Clis = " & glCli
adoRS1.Open sSql, gadoConnDB, adOpenStatic, adLockOptimistic
If adoRS1.EOF Then
adoRS1.AddNew
End If
adoRS1("Clis") = glCli
adoRS1("Package") = CboPackageType.ItemData(CboPackageType.NewIndex)
adoRS1("Provider") = CboProviderType.ItemData(CboProviderType.NewIndex)
'If tickProgrammed.Value = 0 Then
'adoRS1(tickProgrammed.DataField) = False
'Else
'adoRS1(tickProgrammed.DataField) = True
'End If
For Each txtEntry In txtIPDetails
adoRS1(txtEntry.DataField) = Trimmer(txtEntry.Text)
Next
adoRS1.Update
cmdUpdateContact.Enabled = False
End Sub
Selecting Item In Listbox
I can load items into a list box at Form_Load with no problems. Is it possible to process code based on the users selection from the list without using a command button.
Selecting Item In Listbox
I have this code:
Code:
For i = lstKeywords.ListCount - 1 To 0 Step -1
If InStr(lstKeywords.Text, strFilter(k)) Then
MsgBox "Found negative keyword" & lstKeywords.Text
lstKeywords.RemoveItem i
End If
Next i
But it doesn't loop through each item in the listbox. I don't know how to point to a specific row in the listbox and hence my problem. I know I should be using i somehow but not sure what the method is.
Do I use lstKeywords.Selected(i) or something like that?
Selecting An Item In A Listbox
Hi All,
I have a listbox with a popup menu when I right-click on one of the names in the list. This all works fine, but in order to make this work properly I have to first left click on the name I want to select, then I can right click to bring up the popup menu.
I'm wondering if there is a way I can just right click directly onto my chosen name in the listbox without first having to left click to select it?
Anyone have any ideas?
Thanks,
Selecting Combo Box Item Vb6
if i have a combobox with this items:
VB Code:
cmdButtonStyle.Clear cmdButtonStyle.AddItem ("Normal") cmdButtonStyle.ItemData(cmdButtonStyle.NewIndex) = 0 cmdButtonStyle.AddItem ("Soft") cmdButtonStyle.ItemData(cmdButtonStyle.NewIndex) = 1 cmdButtonStyle.AddItem ("Flat") cmdButtonStyle.ItemData(cmdButtonStyle.NewIndex) = 2
how do i get the combo box to select Soft on formload (ie without user selecting it).
sorry if its a simple vb question (at least it will be easy to answer it then).
Selecting Item In Combo
Hi, I have a combo box with items in it. I want to put in a line of code so that when the user presses a cancel button the first ite in the combo box will be selected. Can anyone give me this code please?
Thanking you in advance for your time and help.
PORRASTAR
Selecting A Item In A List Box
How can I select a spesific item on a listbox, without having focus on it? For example:
In a textbox I write: vb
The listbox's selection jumps to: vbforum
how do I do this?
ListBox - Selecting An Item In Another Box
Hey there,
I'm sure this is a realyl easy one but I can't seem to find it in the books I have.
I have two list boxes (we'll call them lst1 and lst2). Each have the same number of items in them. I want to set it so that when one of the items in either box is selected, it automatically selects the corresponding item in the other box so they are both highlighted.
Can someone help me out with this?
I can get which item is clicked with lst1.listindex but then how to I make that same index numebr in the other box get selected?
Thanks,
--Mike
Selecting An Item In A Combo Box
I have a combo box ( style = vbComboDrop-DownList) which displays a list of countries.
My problem is given a particular country name (string) how do I select that item in the combo without having to iterate through each item of the combo.
For example , so far what I have been doing is this
Combo1.text = "United States of America"
but just found out that if the string doesn't exist in the list then I get a run time error 'property is read-only'. eg. when I try to set the text property.
Listbox Item Selecting
I'm using VB5. I want to highlight and copy a number of items in a listbox to the clipboard. I can only highlight one item at a time.
SELECTING AN ITEM FROM A COMBO BOX
Hello all,
Im in the middle of a project that asks me to create a sequential file and add data to it i.e. a message , then a date, so that they are linked, however the dates from this file should then be automatically added to a combo box on the form so that a user can click a date and the related message will appear in the picture box next to it. Ive managed the sequentail file part and iv added the dates to the combo box but i cant find the code that will display the message when a date is chosen by the user. I can manage it with a list box as i use the listbox.selected (I) option but that is not available for a combo box and I have to use a the combo box in the project.
I also cant find the code to relate that date to the message stored in the sequential file so that it can be shown in the picture box. Can anyone help
Here is the code I have so far
Code:
Option Explicit
Dim intstarlog As Integer
Private Type Starlog
strMessage As String
strDate As String
End Type
Dim recLog As Starlog
Private Sub Form_Load()
Dim Starlog As Integer
Starlog = 1
Open "C:Starlog" For Output As #Starlog
Close #Starlog
End Sub
Private Sub cmdAdd_Click()
Dim intmem As Integer
Dim Starlog As Integer
recLog.strMessage = ""
recLog.strDate = ""
recLog.strMessage = InputBox("Please type your message in now", "Star Log")
recLog.strDate = InputBox("Please type in the date,Example :--/--/----", "Star Log")
Starlog = 1
Open "C:Starlog" For Append As #Starlog
Write #Starlog, recLog.strMessage, recLog.strDate
Close #Starlog
comDate.AddItem recLog.strDate
For intmem = 0 To comDate.ListCount - 1
If comDate.ListIndex >= 0 Then
picDisplay.Print recLog.strMessage
End If
Next intmem
End Sub
Again thanks for any help
chris
VB6 Selecting More Than One Item From A Grid
I am using VB6 and I wanted to know how can I select multiple items and store selected/highlighted items into an array or something from a Grid? What kind of Grid do you think I should be using? Right now I am trying it out with MSHFlexGrid, but I cant figure out how to iterate through highlighted items.
Thanks
PJOFNJ
Selecting A DataCombo's Item
I have populated a data combo as given:
Set DataCombo.RowSource=RecSet
DataCombo.ListField="Field1"
DataCombo.BoundColumn="Field2"
At runtime no item is dispayed in combo, unless we select one from the populated items. I want that whenever the form containing DataCombo is loaded, combo's first item is selected.
Any Help...
Selecting A Item From A ComboBox
Hi,
I have a form which allows users to enter details and save them to a table in a access database. Users use a mix of text boxes and ComboBoxes to enter the required data.
I have comboboxes which pull data from two lookup tables and insert the ID of their selection in the table which is great.
The problem comes when I come back to this form to view the entered data.
Both the ComboBoxes are empty. How can I get the ComboBoxes to set their default value to match that of their corresponding value in the table.
Heres my code so far:
------
Private Sub Form_Activate()
'On Error GoTo errHandler
Dim sSql As String
Dim adoRSA As ADODB.Recordset
Dim adoField As ADODB.Field
Dim lCol As Long
Dim lRow As Long
Dim lWidth As Long
Dim labEntry As Label
Dim txtEntry As TextBox
Dim vArr As Variant
Dim lX As Long
Dim sHide As String
If Me.Tag = "loaded" Then Exit Sub
Me.Tag = "loaded"
Me.Icon = frmAccount.Icon
'txtEdit.Visible = False
'load IP details
sSql = "SELECT IPdetails.* " & _
"FROM IPdetails WHERE Clis = " & glCli
Set adoRS1 = gadoConnDB.Execute(sSql)
If Not adoRS1.EOF Then
'If adoRS1(tickProgrammed.DataField) Then
'tickProgrammed.Value = 1
'Else
'tickProgrammed.Value = 0
'End If
For Each txtEntry In txtIPDetails
txtEntry.Text = adoRS1(txtEntry.DataField)
'If tickProgrammed.Value Then
'txtEntry.BackColor = &H8080FF
'Else
'txtEntry.BackColor = &H80000005
'End If
Next
'framePBX.Tag = .TextMatrix(.Row, 2) 'save lCli
Else
For Each txtEntry In txtIPDetails
txtEntry.Text = ""
txtEntry.BackColor = &H80000005
Next
'tickProgrammed.Value = 0
'framePBX.Tag = .TextMatrix(.Row, 2) 'save lCli
End If
Dim strSQL As String 'Declare the variables we need
'Load the data
'** change this SQL to load the data you want.
strSQL = "SELECT * FROM PackageType"
'** change oConn to the name of your Connection object
Set adoRScombo1 = gadoConnDB.Execute(strSQL)
'Fill the combo box (or ListBox)
'** change the name of the combo to the one you want to fill
With CboPackageType
.Clear
'Do While Not adoRScombo1.EOF
'** change the name of the field here to the one you want to show
'.AddItem adoRScombo1.Fields("Package").Value
'adoRScombo1.MoveNext
Do Until adoRScombo1.EOF
CboPackageType.AddItem adoRScombo1.Fields("Package").Value & ""
CboPackageType.ItemData(CboPackageType.NewIndex) = adoRScombo1.Fields("PackageId").Value
adoRScombo1.MoveNext
Loop
'If CStr(CboPackageType.ItemData(CboPackageType.NewIndex)) = CStr(adoRS1("Package")) Then
'CboPackageType = True
'Else
'End If
End With
'Tidy up
adoRScombo1.Close
Set adoRScombo1 = Nothing
Dim strSQL2 As String 'Declare the variables we need
'Load the data
'** change this SQL to load the data you want.
strSQL2 = "SELECT * FROM ProviderName"
'** change oConn to the name of your Connection object
Set adoRScombo2 = gadoConnDB.Execute(strSQL2)
'Fill the combo box (or ListBox)
'** change the name of the combo to the one you want to fill
With CboProviderType
.Clear
'Do While Not adoRScombo2.EOF
'** change the name of the field here to the one you want to show
'.AddItem adoRScombo2.Fields("Provider").Value
'adoRScombo2.MoveNext
Do Until adoRScombo2.EOF
CboProviderType.AddItem adoRScombo2.Fields("Provider").Value & ""
CboProviderType.ItemData(CboProviderType.NewIndex) = adoRScombo2.Fields("ProviderId").Value
adoRScombo2.MoveNext
Loop
End With
'Tidy up
adoRScombo2.Close
Set adoRScombo2 = Nothing
End Sub
Private Sub cmdUpdateContact_Click()
Dim sSql As String
Dim adoRS1 As New ADODB.Recordset
Dim txtEntry As TextBox
'update ip data
sSql = "SELECT IPdetails.* " & _
"FROM IPdetails WHERE Clis = " & glCli
adoRS1.Open sSql, gadoConnDB, adOpenStatic, adLockOptimistic
If adoRS1.EOF Then
adoRS1.AddNew
End If
adoRS1("Clis") = glCli
adoRS1("Package") = CboPackageType.ItemData(CboPackageType.NewIndex)
adoRS1("Provider") = CboProviderType.ItemData(CboProviderType.NewIndex)
'If tickProgrammed.Value = 0 Then
'adoRS1(tickProgrammed.DataField) = False
'Else
'adoRS1(tickProgrammed.DataField) = True
'End If
For Each txtEntry In txtIPDetails
adoRS1(txtEntry.DataField) = Trimmer(txtEntry.Text)
Next
adoRS1.Update
cmdUpdateContact.Enabled = False
End Sub
------
Selecting/Highlighting Item Within Listbox (with VBA)
How do I select a given item within a listbox using VBA? I have a listbox that records ranges from a Refedit control. However, if the user has selected an invalid range, I want to let them see a meaningful message, set the focus to the listbox and then select/highlight the invalid range.
Displaying the message and setting the focus to the listbox is easy, but selecting the item is something I don't know how to do.
Any suggestions?
Selecting Item In Listbox With Right-click
Hi,
Is it possible to select a item in a listbox with a right-click of the mouse. I have a popup menu that must run when the right mouse button is clicked on a item in the listbox.
The problem is that the item is not selected when I right-click on it. The popup menu displays 100% but the item stays unselected. I first have to left-click on the item to select it and then right-click to popup the menu.
Bezzie
ContextMenu, Selecting ListBox Item After
Code:
Private Sub ClientList_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'If Right Click on Client List, Give Menu For Kicking
If Button = 2 Then
PopupMenu SelectClient
End If
End Sub
My code above is for right clicking the client listbox and bringing a contextmenu to the screen. However, I also want it to select the item (Like a left mouse click) if there is not one selected. Also I do not want the feature of right clicking in the clientlist anywhere. I want to select an item first and only be able to rightclick within the item selected. How would I go about doing this? I have been through many pages on the search forum, I didn't find how to accomplish this... unless I am looking under the wrong words, listbox selection, contextmenu selection... The problem is I can rightclick anywhere in the client listbox without selecting an item, and need to force selection.
I tried syntaxs, .list, .listindex, .selected, .listcount, and some others, but I am pretty sure these won't work, I kind of just need a physical selection. Can anyone help?
Combo Box Event For Selecting An Item.
I keep encountering a problem using combo boxes and I need some help.
I'm using a combo box in 2-dropdown mode. I want to respond to whenever the user changes the ListIndex in the combo box. None of the events that are part of the combo box control seem to allow me to do what I want.
Any suggestions.
Thanks.
Selecting An Item In A Listbox Without Clicking
hi,
all day yesterday i've been searching for a code like this but the closest thing can find is a listbox search and its close but not exactly what i want.
lets say i have
a List, a textbox, and a command button.
there are different items in that listbox.
how can i have it so i can type the (exact) name of the item that i'm looking for in the textbox, click the command button.
and then have that item be ***Selected***
the most imortant thing to me is having the item be selected in the listbox without me having to manually click on the listbox.
i can't find this anywhere that i've looked
if someone can help me i'd appreciate it.
Selecting Next Item In List Using A Timer
My program is selecting an item in a list and exectuing code. This is for entering chatrooms. You add the names of a few different chatrooms and click cycle. This code then cycles through the list until it finds a room on your list that isnt' full.
Now is what i want to do is cycle the room on a 5 min timer. I have the code for cycle every 5 minutes.
My problem is i want the cycle to start at the last room it entered. So if it entered the first room on the list, after 5 minutes i want to start to cycle at the 2nd room on the list and so on.
Here is the code i currently have
code:
StopBust = False
Do: DoEvents
inRoom = BustPrivate(List2.List(0))
If inRoom = False Then
inRoom = BustPrivate(List2.List(1))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(2))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(3))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(4))
End If
Loop Until (inRoom = True) Or (StopBust = True)
end code:
Selecting First Item In Sorted Treeview
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
Selecting Item In Combo Box Via Code
What's the method to select an item in a combo box and make it show up in the closed combo box?
Eg. I populate a combo box with 15 items by code. Now nothing is selected. I want to make an item visible. What method do I use it and what is the syntax?
Thanks.
Selecting An Item In A Checked Listbox Using A Db
Hi,
I'm developing a program which connects to a ms access 2003 database using ADO, this database contains information about computer games. It has the following fields:
GameID
Title
Developer
MyGame
I'm trying to populate a checked listbox with the contents of the title field and then check all the titles which have "Yes" in the MyGame field. I managed to populate the list with the titles using this code...
VB Code:
'Clear the games list frmMain.lstGames.Clear 'Set a new recordset to store the information from the database Set rs = New ADODB.Recordset rs.Open "Select GameID, Title, MyGame From Games", cn, , adLockOptimistic Do Until rs.EOF With frmMain.lstGames .AddItem rs.Fields("Title").Value .ItemData(frmMain.lstGames.NewIndex) = rs.Fields("GameID").Value End With rs.MoveNext Loop
How would I place a check next to each game title which has "Yes" in the MyGame field?
Also is it possible to stop the user from placing or removing a checkmark when they click on the title in the listbox?
Many thanks in advance
Robert
Selecting Next Item In List Using A Timer
My program is selecting an item in a list and exectuing code. This is for entering chatrooms. You add the names of a few different chatrooms and click cycle. This code then cycles through the list until it finds a room on your list that isnt' full.
Now is what i want to do is cycle the room on a 5 min timer. I have the code for cycle every 5 minutes.
My problem is i want the cycle to start at the last room it entered. So if it entered the first room on the list, after 5 minutes i want to start to cycle at the 2nd room on the list and so on.
Here is the code i currently have
code:
StopBust = False
Do: DoEvents
inRoom = BustPrivate(List2.List(0))
If inRoom = False Then
inRoom = BustPrivate(List2.List(1))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(2))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(3))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(4))
End If
Loop Until (inRoom = True) Or (StopBust = True)
end code:
|