Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > Windows Forms

Windows Forms Discussion related to Winforms application development

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-07-2009, 6:18 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2009
Posts: 7
Reputation: 0
avi4ever is on a distinguished programming path ahead
Question What is the coding for Next & Previous Button?

Plz someone help me. I want the coding for next and previous button and its given on my form. I want to fetch the records from my database and display it on my form.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-07-2009, 8:13 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2008
Posts: 85
Reputation: 33
ggunter is on a distinguished programming path ahead
Default

You set up a counter to track your current row. Then use something like this:

Code:
Me.<textbox name>.Text = <dataset name>.<table name>.Rows(<row counter variable>)("<field name>").ToString
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-07-2009, 10:21 AM
VB.NET Forum Idol
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2008
Location: USA
Posts: 877
Reputation: 499
MattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond repute
Default

Here's an example of first, last, previous, and next button clicks.

Code:
	Private Sub uxFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
	Handles uxFirst.Click

		Me.EmployeeBindingSource.MoveFirst()

	End Sub
Code:
	Private Sub uxPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
	Handles uxPrev.Click

		If Me.EmployeeBindingSource.Position > 0 Then
			Me.EmployeeBindingSource.MovePrevious()
		End If

	End Sub
Code:
	Private Sub uxNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
	Handles uxNext.Click

		If Me.EmployeeBindingSource.Position < Me.EmployeeBindingSource.Count - 1 Then
			Me.EmployeeBindingSource.MoveNext()
		End If

	End Sub
Code:
	Private Sub uxLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
	Handles uxLast.Click

		Me.EmployeeBindingSource.MoveLast()

	End Sub
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-07-2009, 10:45 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,328
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

You don't have to check the BindingSource.Position MattP, the Move.. methods calls this property and the setter adjusts it automatically.

In relation to this, if you are setting things up manually you can add a BindingNavigator to form from toolbox and assign it your BindingSource, the navigator will the connect to and use the source methods and properties automatically. Perhaps you can also read about using the wizards to setup the data access and form bindings for you.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-07-2009, 11:29 AM
VB.NET Forum Idol
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2008
Location: USA
Posts: 877
Reputation: 499
MattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond repute
Default

Quote:
Originally Posted by JohnH View Post
You don't have to check the BindingSource.Position MattP, the Move.. methods calls this property and the setter adjusts it automatically.
Good to know. I didn't even think to check that when I slapped the example together.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-07-2009, 2:00 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2009
Posts: 7
Reputation: 0
avi4ever is on a distinguished programming path ahead
Question Codin for to connect

Well i m using vb.net 2008 & my back-end is SQL Server 2005. I need it badly
Plz giv me the most easiest codin. Here is the design of my form1:
Label-FName Textbox1.Text
Label-LName Textbox2.Text

Button1-Next Button2-Previous
Button3-Update

After dis take two radio button one for "View" & another for "Edit". After dis the main problem comes i want to see the database details(fname, lname) in dis form1. And about the radio button the moment i'll select "View" radio button it should display the details(fname, lname) bt the textfield1 & 2 wil be disabled & when i'll click "Edit" radio button it should also display the details bt da textfields1 & 2 will be enabled so i can edit n "Update". And if u can give me the codings for database connection i'll be grateful to you. Thank You
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-07-2009, 3:17 PM
VB.NET Forum Idol
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2008
Location: USA
Posts: 877
Reputation: 499
MattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond repute
Default

I would go here 1st. They will show you how to connect to a database and bind controls. If you want to write your own BindingNavigator functionality afterwards then you can take the advice given previously in the thread.

Forms over Data Video Series
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 11:04 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.