473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to make sure ComboBox select nothing...

Hi,

I'm having problem with ComboBox. I'm trying to force the ComboBox select
nothing by doing this,
myCombo.SelectedText = ""
myCombo.SelectedIndex = -1
but in vain, as the ComboBox will automatically select the first available
selection.

If I make the ComboBox visible before setting the .SelectedText to "" and
the .SelectedIndex property to -1, it will be successful. But if I put the
ComboBox in a TabControl and I switch between the Tabs in the TabControl,
the ComboBox will automatically reselect the first available selection.

Anyone out there has a solution?

Thanks in advance.
Jul 19 '05 #1
9 3883
Add an empty object to the combobox options :)

"Programatix" <pr*********@nospam.com> escribió en el mensaje
news:uX**************@tk2msftngp13.phx.gbl...
Hi,

I'm having problem with ComboBox. I'm trying to force the ComboBox select
nothing by doing this,
myCombo.SelectedText = ""
myCombo.SelectedIndex = -1
but in vain, as the ComboBox will automatically select the first available
selection.

If I make the ComboBox visible before setting the .SelectedText to "" and
the .SelectedIndex property to -1, it will be successful. But if I put the
ComboBox in a TabControl and I switch between the Tabs in the TabControl,
the ComboBox will automatically reselect the first available selection.

Anyone out there has a solution?

Thanks in advance.

Jul 19 '05 #2
Hello,

"Programatix" <pr*********@nospam.com> schrieb:
I'm having problem with ComboBox. I'm trying to force the
ComboBox select
nothing by doing this,
myCombo.SelectedText = ""
myCombo.SelectedIndex = -1
but in vain, as the ComboBox will automatically select
the first available selection.


Try to call "myCombo.SelectedIndex = -1" twice, somethimes that helps.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Jul 19 '05 #3
What if I binded the ComboBox to a DataSource?

Thanks for the respond.

"Juan C. Olivares" <ju*****@TAGnet.org> wrote in message
news:eD*************@TK2MSFTNGP10.phx.gbl...
Add an empty object to the combobox options :)

"Programatix" <pr*********@nospam.com> escribió en el mensaje
news:uX**************@tk2msftngp13.phx.gbl...
Hi,

I'm having problem with ComboBox. I'm trying to force the ComboBox select nothing by doing this,
myCombo.SelectedText = ""
myCombo.SelectedIndex = -1
but in vain, as the ComboBox will automatically select the first available selection.

If I make the ComboBox visible before setting the .SelectedText to "" and the .SelectedIndex property to -1, it will be successful. But if I put the ComboBox in a TabControl and I switch between the Tabs in the TabControl, the ComboBox will automatically reselect the first available selection.

Anyone out there has a solution?

Thanks in advance.


Jul 19 '05 #4
It did, but as I have state, if I put the ComboBox into a TabControl and
switched between the Tabs in the TabControl, the ComboBox will reselect the
first available option.

I'm thinking of expanding the ComboBox by inheriting it but could not think
of a way to code it. Any idea?

"Herfried K. Wagner" <hi*******@m.activevb.de> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello,

"Programatix" <pr*********@nospam.com> schrieb:
I'm having problem with ComboBox. I'm trying to force the
ComboBox select
nothing by doing this,
myCombo.SelectedText = ""
myCombo.SelectedIndex = -1
but in vain, as the ComboBox will automatically select
the first available selection.


Try to call "myCombo.SelectedIndex = -1" twice, somethimes that helps.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet

Jul 19 '05 #5
I select the records into a dataset, then add a row with a description of
"<None>" and a value of DbNull.Value. Then I bind the combo box to that
dataset.

This lets users actually put a null in the database when appropriate. I
don't think your current efforts will achieve this.

Regards

Ron

"Programatix" <pr*********@nospam.com> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Hi,

I'm having problem with ComboBox. I'm trying to force the ComboBox select
nothing by doing this,
myCombo.SelectedText = ""
myCombo.SelectedIndex = -1
but in vain, as the ComboBox will automatically select the first available
selection.

If I make the ComboBox visible before setting the .SelectedText to "" and
the .SelectedIndex property to -1, it will be successful. But if I put the
ComboBox in a TabControl and I switch between the Tabs in the TabControl,
the ComboBox will automatically reselect the first available selection.

Anyone out there has a solution?

Thanks in advance.

Jul 19 '05 #6
That's a great idea. How come I never thought of that.
Thanks.

"Ron McNulty" <rm******@xtra.co.nz> wrote in message
news:Ov**************@TK2MSFTNGP12.phx.gbl...
I select the records into a dataset, then add a row with a description of
"<None>" and a value of DbNull.Value. Then I bind the combo box to that
dataset.

This lets users actually put a null in the database when appropriate. I
don't think your current efforts will achieve this.

Regards

Ron

"Programatix" <pr*********@nospam.com> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Hi,

I'm having problem with ComboBox. I'm trying to force the ComboBox select nothing by doing this,
myCombo.SelectedText = ""
myCombo.SelectedIndex = -1
but in vain, as the ComboBox will automatically select the first available selection.

If I make the ComboBox visible before setting the .SelectedText to "" and the .SelectedIndex property to -1, it will be successful. But if I put the ComboBox in a TabControl and I switch between the Tabs in the TabControl, the ComboBox will automatically reselect the first available selection.

Anyone out there has a solution?

Thanks in advance.


Jul 19 '05 #7
Okay, here's kind of a crazy idea (but one that ought to work): Create
your own class that implements IList. In your class's constructor, take
a parameter of type IListSource; call IListSource.GetList(), and save a
reference to the IList that's returned. Then implement your class's
IList.Count property to return savedList.Count + 1, and have your
IList.Item property return "" for element 0, and otherwise return
savedList[index - 1]. Then create an instance of this class, passing
your DataTable as a parameter to the constructor; and bind your ComboBox
to this object, instead of directly to the DataTable.

Sounds like a bit of a pain, until you consider that you can then re-use
this same class for every combo box in your application...
Programatix wrote:
Ok, there's a problem. I'm using DataRelation. The child Table will use the
primary key column of the parent Table as the value. Since it's a primary
key, I cannot add a NULL value for it.

Sigh...

"Ron McNulty" <rm******@xtra.co.nz> wrote in message
news:Ov**************@TK2MSFTNGP12.phx.gbl...
I select the records into a dataset, then add a row with a description of
"<None>" and a value of DbNull.Value. Then I bind the combo box to that
dataset.

This lets users actually put a null in the database when appropriate. I
don't think your current efforts will achieve this.

Regards

Ron

"Programatix" <pr*********@nospam.com> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Hi,

I'm having problem with ComboBox. I'm trying to force the ComboBox

select
nothing by doing this,
myCombo.SelectedText = ""
myCombo.SelectedIndex = -1
but in vain, as the ComboBox will automatically select the first

available
selection.

If I make the ComboBox visible before setting the .SelectedText to ""

and
the .SelectedIndex property to -1, it will be successful. But if I put

the
ComboBox in a TabControl and I switch between the Tabs in the

TabControl,
the ComboBox will automatically reselect the first available selection.

Anyone out there has a solution?

Thanks in advance.


Jul 19 '05 #8
Sounds like you're binding to it
That causes problems with controls on tab controls

Read this:
http://noiseehc.freeweb.hu/CurrencyManager.html

Basically you need to add the following during the loading
of your form (tabpage is the one containing your combo)
tabpage.BindingContext = form.BindingContext
Also read this:
http://support.microsoft.com/?id=327244
/claes

"Programatix" <pr*********@nospam.com> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Hi,

I'm having problem with ComboBox. I'm trying to force the ComboBox select
nothing by doing this,
myCombo.SelectedText = ""
myCombo.SelectedIndex = -1
but in vain, as the ComboBox will automatically select the first available
selection.

If I make the ComboBox visible before setting the .SelectedText to "" and
the .SelectedIndex property to -1, it will be successful. But if I put the
ComboBox in a TabControl and I switch between the Tabs in the TabControl,
the ComboBox will automatically reselect the first available selection.

Anyone out there has a solution?

Thanks in advance.

Jul 19 '05 #9
Mmmm, the article at http://support.microsoft.com/?id=327244 explain that
the bug is found in .NetFramework 1.0. Since I'm using .NetFramework 1.1,
this means that the bug is not fixed yet.

For the solution found in http://noiseehc.freeweb.hu/CurrencyManager.html,
I'll try it right away.

Thanks for the reference.
"Claes Bergefall" <cl********************@frontec.se> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
Sounds like you're binding to it
That causes problems with controls on tab controls

Read this:
http://noiseehc.freeweb.hu/CurrencyManager.html

Basically you need to add the following during the loading
of your form (tabpage is the one containing your combo)
tabpage.BindingContext = form.BindingContext
Also read this:
http://support.microsoft.com/?id=327244
/claes

"Programatix" <pr*********@nospam.com> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Hi,

I'm having problem with ComboBox. I'm trying to force the ComboBox select nothing by doing this,
myCombo.SelectedText = ""
myCombo.SelectedIndex = -1
but in vain, as the ComboBox will automatically select the first available selection.

If I make the ComboBox visible before setting the .SelectedText to "" and the .SelectedIndex property to -1, it will be successful. But if I put the ComboBox in a TabControl and I switch between the Tabs in the TabControl, the ComboBox will automatically reselect the first available selection.

Anyone out there has a solution?

Thanks in advance.


Jul 19 '05 #10

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

Similar topics

9
by: Programatix | last post by:
Hi, I'm having problem with ComboBox. I'm trying to force the ComboBox select nothing by doing this, myCombo.SelectedText = "" myCombo.SelectedIndex = -1 but in vain, as the ComboBox will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.