Solved

Combobox first use

Posted on 2006-12-01
8
162 Views
Last Modified: 2010-05-18
Hi

I have a problem with the first time that I click on a combobox.

I have
cmbDept.SelectedItem = NewItem
cmbDept.Text = NewItem

which is supposed to display the string in NewItem but it doesn't the first time it is clicked, it displays the first item in the list.
If it is clicked again it displays the string correctly.

All help appreciated.

Regards

0
Comment
Question by:alungwyther
8 Comments
 
LVL 6

Expert Comment

by:manch
ID: 18052585


Why don't u use directly

        cmbDept.SelectedItem = cmbDept.Items(indexOfItemUWantToSelect)

it will work surely

Try It
0
 

Author Comment

by:alungwyther
ID: 18052764
Hi

Thanks for the reply but it didn't work, still came up with the first item in the list.
0
 
LVL 10

Expert Comment

by:Kinger247
ID: 18052880
Where are you running this code ?

So, as I can gather from your code you want to highlight the value of NewItem in the combo cmbDept ?
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 7

Expert Comment

by:dctuck
ID: 18052949
Try:

 cmbDept.Text = NewItem
0
 
LVL 6

Expert Comment

by:manch
ID: 18052983

Now u have to elaborate ur need

Where do u want to set the Item as First or Selected One
r u writing the code in the Event of the ComboBox itself or ur writing it in some other place
and what is ur basic need?

mention it
0
 

Author Comment

by:alungwyther
ID: 18053245
Hi

Solved the problem.
The combobox was not visible until after the text was set. Once I made it visible before then everything worked OK.
Thanks for the replies
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 18088922
PAQd, 125 points refunded.

DarthMod
CS Moderator
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question