473,763 Members | 7,622 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Avoid autoselect in combobox

Avoid autoselect in combobox

In the load procedure of a form I am filling a combobox with data from a
database. The combobox fill the data OK, but it is automatic showing the
first item of the list as the text. How can I avoid the first item in the
list to be selected as default? I want the textbox of the combo to be left
empty until the user select an item.
My Code below:

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

MyDataAdapter.S electCommand.Co mmandText = "SELECT MyDescription, MyID
FROM MyTable"
MyDataAdapter.F ill(MyDataSet)
ComboBox1.DataS ource = MyDataSet
ComboBox1.Displ ayMember = "MyTable.MyDesc ription"
ComboBox1.Value Member = "MyTable.My ID"

End Sub

T.I.Rislaa

Nov 20 '05 #1
2 3280
Try
ComboBox1.Selec tedIndex = ComboBox1.Items .IndexOf("")

"Tor Inge Rislaa" <to************ *@rislaa.no> wrote in message
news:tV******** ***********@new s4.e.nsc.no...
Avoid autoselect in combobox

In the load procedure of a form I am filling a combobox with data from a
database. The combobox fill the data OK, but it is automatic showing the
first item of the list as the text. How can I avoid the first item in the
list to be selected as default? I want the textbox of the combo to be left
empty until the user select an item.
My Code below:

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

MyDataAdapter.S electCommand.Co mmandText = "SELECT MyDescription, MyID
FROM MyTable"
MyDataAdapter.F ill(MyDataSet)
ComboBox1.DataS ource = MyDataSet
ComboBox1.Displ ayMember = "MyTable.MyDesc ription"
ComboBox1.Value Member = "MyTable.My ID"

End Sub

T.I.Rislaa

Nov 20 '05 #2
Thank you, It worked just the way I wanted!

T.I.Rislaa

"scorpion53 061" <sc************ @yahoo.com> skrev i melding
news:u2******** ******@TK2MSFTN GP12.phx.gbl...
Try
ComboBox1.Selec tedIndex = ComboBox1.Items .IndexOf("")

"Tor Inge Rislaa" <to************ *@rislaa.no> wrote in message
news:tV******** ***********@new s4.e.nsc.no...
Avoid autoselect in combobox

In the load procedure of a form I am filling a combobox with data from a
database. The combobox fill the data OK, but it is automatic showing the
first item of the list as the text. How can I avoid the first item in the list to be selected as default? I want the textbox of the combo to be left empty until the user select an item.
My Code below:

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

MyDataAdapter.S electCommand.Co mmandText = "SELECT MyDescription, MyID FROM MyTable"
MyDataAdapter.F ill(MyDataSet)
ComboBox1.DataS ource = MyDataSet
ComboBox1.Displ ayMember = "MyTable.MyDesc ription"
ComboBox1.Value Member = "MyTable.My ID"

End Sub

T.I.Rislaa


Nov 20 '05 #3

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

Similar topics

13
2799
by: Mr. B | last post by:
Here's the situation... You've a combobox with Items already added. Say they look like this (or even lines of text): 10-00-232 10-00-256 10-01-006 10-01-213 10-02-200
0
1509
by: Jean-Marc Blaise | last post by:
Dear all, The LOAD indexing mode is by default, I presume, "autoselect", and the LOAD should choose between REBUILD or INCREMENTAL. In version 7.2 FP11, so in "offline" mode, with a LOAD INSERT, we got the LOAD choose the REBUILD despite the lack of pages in the tablespace (we had 2Million 16K page free, but this was not enough). Is the behavior the same in V8.1 (I've noticed the READ ACCESS mode only
7
8526
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way of doing it. I have a table with products, tblProducts, some of them are Active while others are Inactive. The form shows all the products purchased by a customer, both Active and Inactive in a ComboBox, cbProducts. My client wants to view all...
5
12110
by: lk | last post by:
Hi there, is it possible to avoid that a user could enter a text directly in a combobox? The user should only select a text from the list of the combobox without typing anything. Thanks
1
2497
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new DataTable("table"); testTable.Columns.Add("Col1", typeof(Int32)); testTable.Columns.Add("Col2", typeof(String)); testTable.Rows.Add(testTable.NewRow());
3
6834
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article: http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx I have a problem when there are two DataGrid's on one form, and when I switch focus from one grid to the other. To be more precise, when I'm editing a combo box column in one grid, and then click in the combo column of...
0
1078
by: magister | last post by:
Hello, I am using the Microsoft TreeView control... There is one property called AutoSelect which on the MSDN says "Activates Keyboard Hovering" I have searched the web for what keyboard hovering is and cannot find anything actually what this means..... Can anyone tell me what this property actually does I would be
2
1751
by: Pepi Tonas | last post by:
I am using a combobox in an application, where I don't want the text to be changed, limiting the displayed text to those assigned to each item in the control's item collection. I don't want to allow users to type in anything into the control's textbox and limit them to only be able to choose from its list. Thanks...
4
3413
by: Larry Woods | last post by:
I need to implement autoselect in a combobox. Anyone know how? TIA, Larry Woods
0
9387
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3528
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.