473,806 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding BindingSource.P osition from Listbox Selection

Hi,
I'm have a form with a listbox and a few textboxes on it. Based on
the user's selection in the listbox, I want the bindingsource to
update the textboxes with the corresponding values. I have similar
code built for a combobox that works just fine, but when applying it
to a listbox bound to a dataview, I can't figure out how to return the
correct bindingsource index. No matter what item I select, my index
returns 0.

Private Sub lbUOM_SelectedI ndexChanged(ByV al sender As Object, ByVal e
As System.EventArg s) Handles lbUOM.SelectedI ndexChanged

cn.Open()

Dim drv As DataRowView = CType(lbUOM.Sel ectedItem,
DataRowView)
tb.Text = drv.Item("USUOM ").ToString

Dim index As Integer = bsUOM.Find("USU OM", tb.Text)
If index <-1 Then 'it was found; move to that
position
bsUOM.Position = index
End If

cn.Close()
End If
End Sub

Can anybody see why this doesn't work? Is there a better way to
navigate the bindingsource based on a listbox selection? I don't see
this issue posted anywhere in this board.

Thanks,
Randy

May 21 '07 #1
5 3598
Anybody want to take a crack at this? Thanks.

May 22 '07 #2
(sound of crickets chirping)...

May 23 '07 #3
(sound of crickets chirping)...

May 23 '07 #4
Hi Randy,

Did you find a solution to this? I have a combo box bound to a Access db Table - column 1. When the combo item is selected I want the same records column 2 entry to display in a text box. I'm struggling to get a decipherable explanation on how to use BindingSource for .net 2005.

Any help would be gratfully received.

Thanks,
Nick

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Nov 7 '07 #5
Nick,

That goes automaticly as you databind the textbox to a table, and you do the
same for the combobox using the datasource, then the currencymanager will
set the current table-item in the textbox.

You even need a New DataView for not doing that.

I would use this newsgroup for information instead of the by you quoted one.
This is common stuff here.

Cor

Nov 8 '07 #6

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

Similar topics

9
4050
by: Irene | last post by:
I'm developing a Web application where a user selects from a listbox which can have many items. The initial display only shows about 10 items. After a postback, the listbox is automatically scrolled back to the top, so the selected item is mostly no longer visible. How can I keep the position, so that the selected item is still shown?
2
6812
by: (Pete Cresswell) | last post by:
Seems like I've been here before, but can't find anyting in Google. I've got two list boxes on a form. Seems to me like the inactive ListBox's selection rectangle should be something like gray...otherwise, the user sees two ListBoxes, both with black selection rectangles - and the user does not visually know which one he is "in". This becomes relevant if we have a keyboard-type user - they want to hit "Enter" and have something...
6
30036
by: Dan Bass | last post by:
If you look at explorer, right clicking on a file, first selects the file, then throws up the context menu relating to that selection. With a Windows ListBox control and a simple context menu, the default behaviour seems to display the context menu on the listbox, but there is no selection. Now I know that explorer's using a listview, and that the context menu acts differently if you click on open space (no selection), but can I...
6
12924
by: Alpha | last post by:
I have a listbox with datasource from a dataview. When a user selects a different item in a combobox then I need to refresh the listbox to the appropriate listing based on that combobox's selected value which is included in the listbox's filtering statement. Is the only way to do this is to dispose the dataview and then create a new one and then bind it to the listbox? Is there a better way than this? Thanks, Alpha
0
4160
by: Geoff | last post by:
Hi folks Calling BindingSource.ResetCurrentItem() is changing the BindingSource.Position in a way I don't understand. If I'm understanding the docs correctly, ResetCurrentItem() should simply trigger an event which causes controls to refresh with the values of the current item with the index BindingSource.Position. This is not what I'm seeing.
9
3250
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback). This listbox has AutoPostback = True. When the user selects an item from this list, the second listbox is populated with more items relevant to this selection. I am using an SQLDataSource web control for this. These items are headers. I want, when...
4
1459
by: kimiraikkonen | last post by:
Hi, I have a odd but a known question about listbox. I know listbox control can provide multi-select, multi-extendend selections. But i wonder if this selection type belongs to them or it has another tecnique. As you may know, in softwares like Windows Media Player or Winamp playlist has a listbox and it can be selected in 2 types. First type refers to player's own selection and second selection type can be done by user to look for...
1
12158
by: =?Utf-8?B?Rm9lZg==?= | last post by:
I have a BindingSource with an underlying table with two primary keys. To set the position with one primary key works fine as shown in the code snippet below: Dim index As Integer = myBindingSource.Find("ColumnName", myColumnName) If (index <-1) Then myBindingSource.Position = index End If How should I set the BindingSource.Position with two or more primary keys?
2
12734
by: Ramk | last post by:
I have a listbox on my form which is bounded to a bindingsource. The collection is of type List<T>. If I add new elements to the bindingsource, I would like to select them in the listbox. A sample like the following is working...but it is not working when the list contains an object. int cnt = listBox2.Items.Count; for (int i = cnt; i < (cnt + 10); i++) { bindingSource2.List.Add(i.ToString());
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
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
10618
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...
1
10371
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
7649
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
6877
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
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 we have to send another system
2
3850
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.