Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with databinding

Status
Not open for further replies.

RocAFella2007

Technical User
Joined
Mar 21, 2007
Messages
45
Location
GB
Hi everyone, I need some help with the following it is quiet simple really but its been really stressing me out as I have spent many hours trying to figure out how to do it. I have a form which is databinded to a table, in the form there is a listbox, 2 buttons and 2 textboxes. The idea of the program is simple, in the listbox it shows the description of the item (in any random order), the two textboxes are binded to the database and the first textbox shows the description of the item, and the second textbox shows a specific number which is related to the item.

Also the buttons are placed next to the listbox and their role is simple, one is an ‘up’ button and one is a ‘down’ button. They navigate through the chosen item in the listbox, however they also move on to the next/previous item in the textbox, for example I have included the following coding which is with the down button:

dbindingmanager.Position += 1

'Make the selected item go lower in listbox1
If Me.listbox1.SelectedIndex <> Me.listbox1.Items.Count - 1 Then
Me.listbox1.SelectedIndex = Me.listbox1.SelectedIndex + 1
End If

The part I need help with is there a way in which the item in the listbox matches the item in the textbox, the part im having trouble with is the up and down buttons only move on to the next/previous record in the textbox and not matching the same item which is shown in the listbox, I need the item that is showing in the listbox to be the same as the item in the textbox. I have included a print screen of my program, if you can give me any suggestions or help me out I would really appreciate it.

Thanks alot.

455soas.jpg


(By the way the above is incorrect as I have entered the text in the two textboxes) but I hope you get my drift.
 
Are the textboxes and listbox all bound to the same datasource? Not the same database/table, but to the same .NET datasource such as a datatable, dataview, etc.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Im sorry i dont know what you mean, what i done was install the oledbdataadapter on the form, from the oledbdataadapter i created a new dataset. After that i selected the textbox, in the properties i chose 'databinding' then 'text' then the correct part to the table. The listbox is not databinded.
 
So far I have the following on the up and down buttons

dbindingmanager.Position -= (Listbox1.SelectedItem)

dbindingmanager.Position += (Listbox1.SelectedItem)

but, it keeps breaking. I know it cant be much difficult than this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top