![]() |
Click here to advertise with us
|
|
|||||||
| Windows Forms Discussion related to Winforms application development |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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.
|
|
|||
|
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
|
|
|||
|
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 |
|
||||
|
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.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
Good to know. I didn't even think to check that when I slapped the example together.
|
|
|||
|
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 |
|
|||
|
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 |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|