473,473 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Selected text in a ComboBox

I have the following code:
.cboBox1.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox2.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox6.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox1.SelectedIndex = 0
.cboBox2.SelectedIndex = 1
.cboBox6.SelectedIndex = 2
When this form opens, A, B, and C are all highlighted in their respective
controls. I have tried the following ways to unhighlight the text but
without success.

.cboBox6.SelectionLength = 0
.cboBox6.Select(0, 0)
.cboBox1.Focus()

Is there a way to unhighlight the text in the comboboxes that do not have
focus?

Nov 21 '05 #1
4 7600
Set them to -1
.cboBox1.SelectedIndex = -1
.cboBox2.SelectedIndex = -1
.cboBox6.SelectedIndex = -1

"genojoe" <ge*****@discussions.microsoft.com> wrote in message
news:32**********************************@microsof t.com...
I have the following code:
.cboBox1.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox2.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox6.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox1.SelectedIndex = 0
.cboBox2.SelectedIndex = 1
.cboBox6.SelectedIndex = 2
When this form opens, A, B, and C are all highlighted in their respective
controls. I have tried the following ways to unhighlight the text but
without success.

.cboBox6.SelectionLength = 0
.cboBox6.Select(0, 0)
.cboBox1.Focus()

Is there a way to unhighlight the text in the comboboxes that do not have
focus?

Nov 21 '05 #2
This solution does not work because I want to actually display values in each
comboBox. I tried the following code and each item still remained
highlighted.

.cboBox1.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox2.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox6.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox1.SelectedIndex = -1
.cboBox2.SelectedIndex = -1
.cboBox6.SelectedIndex = -1
.cboBox1.Text = "A"
.cboBox2.Text = "B"
.cboBox6.Text = "C"

"Some Guy" wrote:
Set them to -1
.cboBox1.SelectedIndex = -1
.cboBox2.SelectedIndex = -1
.cboBox6.SelectedIndex = -1


Nov 21 '05 #3
It works

ComboBox1.SelectedText = "A"
ComboBox2.SelectedText = "B"
ComboBox3.SelectedText = "C"
ComboBox1.SelectedIndex = -1
ComboBox2.SelectedIndex = -1
ComboBox3.SelectedIndex = -1


"genojoe" <ge*****@discussions.microsoft.com> wrote in message
news:24**********************************@microsof t.com...
This solution does not work because I want to actually display values in
each
comboBox. I tried the following code and each item still remained
highlighted.

.cboBox1.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox2.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox6.Items.AddRange(New Object() {"A", "B", "C"})
.cboBox1.SelectedIndex = -1
.cboBox2.SelectedIndex = -1
.cboBox6.SelectedIndex = -1
.cboBox1.Text = "A"
.cboBox2.Text = "B"
.cboBox6.Text = "C"

"Some Guy" wrote:
Set them to -1
.cboBox1.SelectedIndex = -1
.cboBox2.SelectedIndex = -1
.cboBox6.SelectedIndex = -1

Nov 21 '05 #4
You are correct. I finally went to a new project and could duplicate your
result. In my actual application, however, I still ended up with all
combobox text highlighted. Below is my actual abridged code that, frankly,
does not make sense and seems to indicate some kind of bug in .NET

FYI: In the actual application, I had the following line of code associated
with each combobox in the parent form:

Me.cboBox2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)

I then opened the form with:
Dim mfrmCommon As frmCommon = New frmCommon
With mfrmCommon
.......................Set text, etc. for various controls on form
.ShowDialog()
End With

When opening frmCommon this way, every combobox was highlighted. I added
the following line of code in the With statement for each combobox and the
problem went away.

.cboBox1.Anchor = CType((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)

I short, I changed the combobox anchor from top, left, right to top, left to
solve the problem. Go figure.
"Some Guy" wrote:

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marcus Peters | last post by:
Hi folks, I need to copy the selected text in any other application to the clipborad. I played around with several ways which did not work: Win API: Send a Message with WM_COPY --> Worked...
0
by: Charlie | last post by:
I have the following code but I can't get the selected text to highlight correctly. What happens is all the text after the selected text is red. I need to add that after the selected text is...
5
by: Hassan Bassam | last post by:
I am having a problem. How can I get the selected text from a text editor. I am using ASP.NET and VB as language. Thanx
5
by: mark_hanson_eng | last post by:
How can I best pass user selected text to the server on a button click? I could use javascript document.selected and add javascript to a asp:button using Attributes.Add. Ideally I would fill the...
2
by: trebor | last post by:
If you select text in a form's textbox and then open a second form (for whatever reason), the selected text no longer looks selected; it's not hilited. When you close the second form and return to...
4
by: Adnan Siddiqi | last post by:
Hi Pardon me if I am not making any sense.What I want to know the cordinates of selected text by user so that i can save/retrieve them later.is It possible.I am lookig for both IE and Firefox...
3
by: Dekortage | last post by:
Hi all... I am able to grab the text that a user has selected on a web page, using this code: function moreInfo() { if (!isIE) { var t = window.getSelection(); // act on variable "t";
1
by: julianomartins | last post by:
Hi friends, how I make to recoup the value of database and to keep selected in combobox to edit my form? in script below it is selected field of the table that possesss id of the first item of...
0
by: darith | last post by:
Hello all, I want vb.net code to get selected text from Ms word. Could you kindly help me? For example, Imports Microsoft.Office.Core Imports Microsoft.Office.Interop Dim wapp As...
1
by: destiny007 | last post by:
can any one help me to write code to capture selected text from a page but problem is that i am not able to decide where to call the functio.in this case the function is called in all cases of mouse...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...
0
muto222
php
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.