Search
VB
-
Tips
Visual Basic .Net tips and tricks
1
Previous
Next
CurrencyManager a simple sample
Binding labels (or whatever) to a datagrid (actualy the datasource) is very simple. See this sample, that only needs a datagridview and three labels on a form and than pasting the code bellow in. For the version 2002/2003 the only change is a datagrid for the datagridview
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("Name")
dt.Columns.Add("State")
dt.LoadDataRow(New Object() {"Ken", "Florida"}, True)
dt.LoadDataRow(New Object() {"Cor", "Holland"}, True)
DataGridView1.DataSource = dt
Label1.DataBindings.Add("Text", dt, "Name")
Label2.DataBindings.Add("Text", dt, "State")
Label2.Text = "1"
Dim cma As CurrencyManager = DirectCast(BindingContext(dt), CurrencyManager)
AddHandler cma.CurrentChanged, AddressOf CurrentChanged
End Sub
Private Sub CurrentChanged(ByVal sender As Object, ByVal e As EventArgs)
Label3.Text = DirectCast(sender, CurrencyManager).Position.ToString
End Sub
End Class
1
Previous
Next
Syndication
Rss feed
Select a Category
General Grid Tips
DataGrid Tips
DataGridView Tips
Windows Forms Controls
General Ado.Net Tips
SqlClient Ado.Net Tips
OleDB Ado.Net Tips
Asp.Net Tips
Miscellanous Tips
Vista programming Tips
WPF Tips
Silverlight
Articles
Links
Code Camp
FAQs
VB Related Websites
Microsoft Visual Basic Home Page
Visual Basic .Net Wikipedia Page
Visual Basic Forums
Visual Basic Newsgroup
VB City
Thinq Linq
VB Helper
I love VB