473,511 Members | 14,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to select a combo box item programatically.

neo008
85 New Member
Hi All,

How can I select a combo box item programatically.

I am using VB6 and I have populated a combo box from database.


NE☼
Jun 22 '07 #1
5 42719
debasisdas
8,127 Recognized Expert Expert
Use the listindex property

try like this sample code
----------------------------------------
Expand|Select|Wrap|Line Numbers
  1. text1.text=cobmo1.list(combbo1.listindex)
Jun 22 '07 #2
Killer42
8,435 Recognized Expert Expert
Try setting the .ListIndex property, or the .Text property of the combo box. Depending on exactly what you meant by "select", this may be what you're after.
Jun 23 '07 #3
neo008
85 New Member
Thank you for reply friends. Here I try to elaborate my problem

Expand|Select|Wrap|Line Numbers
  1. Adodc1.Recordset.AddNew
  2.  
  3.                 TempH = InputBox("Enter New Item")
  4.  
  5.                 Adodc1.Recordset.Update
  6.                 Adodc1.Refresh
  7.  
  8.                 Call RefHCompCombo 'POPULATES ITEMS FROM DB
  9.                 Adodc1.Refresh
  10.                 MsgBox "New Item Added Successfully."
New Item is being added successfully but I want that newly added item as current selected item of combo box such that user should not have to again drop it down and select the newly added one.

Function which populates combo box causes combo box "Deselected"

In other cases I'm using Combo1.Text="ITEM NAME" and it works fine. But here it's not working.

Moreover even if it works -

1. Combo1.Text command just puts an string you want to display on combo box, it's not necessarily a combo box item.

2. Even If I give exact text as it's itemname would it behave like a selected item? means listindex property should give it's index by matching text.

I welcome any solutions/suggessions/mistakes/ideas

NE☼
Jun 23 '07 #4
debasisdas
8,127 Recognized Expert Expert
I want that newly added item as current selected item of combo box
try to use

combo1.listindex=combo1.listcount-1

and set SORTED property to FALSE.

and for text use

str=combo1.list(combo1.listindex)


Hope that solves your problem.
Jun 25 '07 #5
neo008
85 New Member
Absolutely solved !!


Thanks Debasisdas !! I didn't try this.

NE☼
Jun 25 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3452
by: passion_to_be_free | last post by:
This is probably simple, but I can't seem to find it anywhere. I have have some values stored in javascript variables. I have a <select> dropdown list whose options correspond to these values. I...
6
29980
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,...
1
7090
by: Ramón | last post by:
why am I not allowed to intanstiate a new task item? TaskItem task_DC = new TaskItemClass(); This is the erro I get when building: error CS0122:...
0
1535
by: CDARS | last post by:
Dear all, I understand that I can bind a DataSet to a RadioButtonList control with properties DataTextField and DataValueField. ASP.NET will have the ListItem objects generated. Nice. Well...
1
1548
by: John | last post by:
Hi, First off .. I am very new to ASP.NET (.NET in general), so this may be a very basic question. I want the user to click anywhere on a row to select an item. I have seen samples where I...
0
2319
by: pradeep | last post by:
Hello, I have problem in PHP String concatination with html select combo box. There are 3 files addressbook.sql : concat1.php concat2.php
7
10313
by: Rotsey | last post by:
Hi, I am having a problem trying to select an item with the enter key. I want to work the combo with the keyboard. So when I use the down arrow to browse the list I want to then hit the...
6
18636
by: naimasora | last post by:
I have a combobox and a listbox. When the user select an item from the combobox, then the listbox will show a certain data. How do I do this? Thank you in advance.
7
4784
by: usr123 | last post by:
Hi, I need a multi select combo box on ASP page. Scenario: on page there is a table with few columns. In multi select box, i need all the table columns,let user select a few, and show only...
0
7237
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,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
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,...
1
7074
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...
0
5659
agi2029
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,...
0
4734
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...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
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 ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.