Monday, July 23, 2007

Data Binding in Vb.net

Private Sub frm_rem_display_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ada As New OleDbDataAdapter("select * from reminders where rdate='" & Today & "'", conn)
Dim ds As New DataSet
ada.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
TextBox1.DataBindings.Add("text", ds.Tables(0), ds.Tables(0).Columns_ (1).ColumnName)
cm = BindingContext(ds.Tables(0))
cm.Position = pos
tot = ds.Tables(0).Rows.Count
Label1.Text = pos + 1 & " of " & tot
Else
TextBox1.Text = "No Reminders For Today!!!!!!!!"
Button1.Enabled = False
Button2.Enabled = False
End If
End Sub


Private Sub btn_view_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_view.Click
If pos > 0 Then
pos = pos - 1
cm.Position = pos
Label1.Text = pos + 1 & " of " & tot
End If
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If pos + 1 < tot Then
pos = pos + 1
cm.Position = pos
Label1.Text = pos + 1 & " of " & tot
End If E
nd Sub

No comments: