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

Finding BindingSource.Position 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_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles lbUOM.SelectedIndexChanged

cn.Open()

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

Dim index As Integer = bsUOM.Find("USUOM", 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 3567
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
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...
2
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...
6
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,...
6
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...
0
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...
9
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)....
4
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...
1
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 =...
2
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.