473,411 Members | 1,880 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,411 software developers and data experts.

Combobox showing first item??

I have used the feedback on this issue to remedy my comboboxes showing
the first item on the list when a new record is added to the binding
context ---
Me.BindingContext(dsOrders, "tblOrders").AddNew()
Me.ComboBox1.SelectedIndex = -1

but... how do we deal with the same issue during record navigation?
When I move forward or backward onto a null field the combo defaults to
the first item on the list again?

Me.BindingContext(dsOrders, "tblOrders").Position =
(Me.BindingContext(dsOrders, "tblOrders").Position + 1)

I am convinced that anyone using combos is having this problem...

I am binding early, clearing and rebinding late, trying many variations
to no avail. I have added an empty string value to the first item of
all my combos - this displays an empty box for null fields, but is not
optimal. Anybody have a workaround for this??

Nov 21 '05 #1
2 2825
ng
I prefer an unbound combobox.

Tom

Nate wrote:
I have used the feedback on this issue to remedy my comboboxes showing
the first item on the list when a new record is added to the binding
context ---
Me.BindingContext(dsOrders, "tblOrders").AddNew()
Me.ComboBox1.SelectedIndex = -1

but... how do we deal with the same issue during record navigation?
When I move forward or backward onto a null field the combo defaults to
the first item on the list again?

Me.BindingContext(dsOrders, "tblOrders").Position =
(Me.BindingContext(dsOrders, "tblOrders").Position + 1)

I am convinced that anyone using combos is having this problem...

I am binding early, clearing and rebinding late, trying many variations
to no avail. I have added an empty string value to the first item of
all my combos - this displays an empty box for null fields, but is not
optimal. Anybody have a workaround for this??

Nov 21 '05 #2
Hi,

"Nate" <na***************@hitchcock.org> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have used the feedback on this issue to remedy my comboboxes showing
the first item on the list when a new record is added to the binding
context ---
Me.BindingContext(dsOrders, "tblOrders").AddNew()
Me.ComboBox1.SelectedIndex = -1

but... how do we deal with the same issue during record navigation?
When I move forward or backward onto a null field the combo defaults to
the first item on the list again?
I recently posted a workaround for what i can only guess deals with your
problem. Are you talking about lookup ComboBox's to which you have added a
binding for SelectedValue ?,eg.:

Me.ComboBox1.Bindings.Add( "SelectedValue", dsOrders,
"tblOrders.SomeFkField" )

If so, then yes there is a problem with null values, and here is a
workaround:

AddHandler Me.BindingContext(dsOrders, "tblOrders").PositionChanged, _
AddressOf CmPositionChanged

Private Sub CmPositionChanged( ByVal sender As Object, ByVal e As
System.EventArgs)
'
Dim cm As CurrencyManager = _
DirectCast(sender, CurrencyManager)
Dim lv As DataRowView = _
DirectCast(cm.Current, DataRowView)
Dim cb As ComboBox

For Each bnd As Binding In cm.Bindings
If (bnd.PropertyName = "SelectedValue") And _
(TypeOf (bnd.Control) Is ComboBox) Then
cb = DirectCast(bnd.Control, ComboBox)
If (lv(bnd.BindingMemberInfo.BindingField) Is DBNull.Value) And _
(cb.SelectedIndex <> -1) Then
cb.SelectedIndex = -1
End If
End If
Next
End Sub
HTH,
Greetings

Me.BindingContext(dsOrders, "tblOrders").Position =
(Me.BindingContext(dsOrders, "tblOrders").Position + 1)

I am convinced that anyone using combos is having this problem...

I am binding early, clearing and rebinding late, trying many variations
to no avail. I have added an empty string value to the first item of
all my combos - this displays an empty box for null fields, but is not
optimal. Anybody have a workaround for this??

Nov 21 '05 #3

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

Similar topics

2
by: Phil | last post by:
My form uses a dataset containing two tables, a base table (Contact) and a lookup table (Insurer). My combobox is bound as follows: DataSource = datasetContact DisplayMember =...
2
by: Anand | last post by:
Hi All, I have a combobox with style as DropDown List. When I set the combobox.selectedIndex = 0, the first value is not showing up in the combobox and it is simply blank. Only if I...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
2
by: Vern | last post by:
I have a combobox called sPropertyCountyCd whose datasource is a dataview. The first time I set the filter to the dataview, attach the combobox to the dataview, and set the selected index to -1 is...
2
by: Tor Inge Rislaa | last post by:
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...
12
by: eetarnold | last post by:
Hi Gurus, As I've read in other posts the past couple of days, I've read many great posts and haven't figured out how I can solve this problem...I'm trying to make a form very user friendly for...
1
by: fiaolle | last post by:
Hi The first set of source code is the class for a combobox in a grid, hopefully. In the second set of code we try to use the combobox class, but the grid is empty. I don't understand how this...
9
by: Franky | last post by:
I have a usercontrol that inherits from ComboBox I'd like to add the feature that the user can delete any item Best would be that he could right click an element and a messagebox would ask if...
0
by: pavanip | last post by:
Hi, I am facing problem with combobox in gridview.I have used combobox in gridview and i am binding data to gridview combobox from database. If i click 2 times on combobox then it is showing the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
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
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
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...

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.