im glad for this sample codes you have shared..but with my limited understanding of the language(vb.net) i would like to ask some questions such as
where am i suppose to insert this codes( or my similar version of codes) (1) Shall i create a sub procedure and insert this codes...(2) or must i insert it in my checkbox's object sub procedure,
also when you say that this is "one of the easiest way of binding data".. are thier also another method which involves more clicking than encoding
here i will give you an example. you can select the radiobutton ,and the listbox will change with your choice.so you will lay out 2 rodiobutton in an groupbox ,and a listbox ,the code is like this.
Imports System.Data.SqlClient
Public Class ListBox Inherits System.Windows.Forms.Form
Private Sub ListBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sqlCon As New SqlConnection("Data Source=NB-fire;Database=SAMPLES;User Id=SAM;Pwd=SAM") Dim sqlAda As SqlDataAdapter Dim ds As DataSet
Dim sql As String = "SELECT ID , NAME , AGE FROM EMPLOYEEINFO" sqlAda = New SqlDataAdapter(sql, sqlCon) ds = New DataSet
Try sqlAda.Fill(ds) Catch ex As Exception MessageBox.Show(ex.Message + Chr(10) + Chr(13) + ex.StackTrace) Return New DataTable
End Try
Return ds.Tables(0)
End Function
Private Sub rbName_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbName.CheckedChanged If Me.rbName.Checked Then Me.ListBox1.DisplayMember = "NAME" End If End Sub
Private Sub rbAge_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbAge.CheckedChanged If Me.rbAge.Checked Then Me.ListBox1.DisplayMember = "AGE" End If End Sub End Class
checkbox.text databinding?
waheyluggage
one of the easiest way of binding data is to use a Binding source
Dim mBindingSource As New BindingSource
mBindingSource.DataSource = ' your datatable
Now you can bind your controls properties to this binding sources datamembers
Control.Databindings.Add( propertyName,dataSource,DataMember)
Me.CheckBox1.DataBindings.Add("Text", mBindingSource, "Name")
For more information check this article
http://msdn2.microsoft.com/en-us/library/ef2xyb33.aspx
I hope it helps, regards
Ayhan
Izzz
im glad for this sample codes you have shared..but with my limited understanding of the language(vb.net) i would like to ask some questions such as
where am i suppose to insert this codes( or my similar version of codes) (1) Shall i create a sub procedure and insert this codes...(2) or must i insert it in my checkbox's object sub procedure,
also when you say that this is "one of the easiest way of binding data".. are thier also another method which involves more clicking than encoding
Clayton Culver
here i will give you an example. you can select the radiobutton ,and the listbox will change with your choice.so you will lay out 2 rodiobutton in an groupbox ,and a listbox ,the code is like this.
Imports System.Data.SqlClient
Public Class ListBox
Inherits System.Windows.Forms.Form
Private Sub ListBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ListBox1.DataSource = Me.GetDataSource()
Me.ListBox1.DisplayMember = "NAME"
Me.ListBox1.ValueMember = "ID"
End Sub
Private Function GetDataSource() As DataTable
Dim sqlCon As New SqlConnection("Data Source=NB-fire;Database=SAMPLES;User Id=SAM;Pwd=SAM")
Dim sqlAda As SqlDataAdapter
Dim ds As DataSet
Dim sql As String = "SELECT ID , NAME , AGE FROM EMPLOYEEINFO"
sqlAda = New SqlDataAdapter(sql, sqlCon)
ds = New DataSet
Try
sqlAda.Fill(ds)
Catch ex As Exception
MessageBox.Show(ex.Message + Chr(10) + Chr(13) + ex.StackTrace)
Return New DataTable
End Try
Return ds.Tables(0)
End Function
Private Sub rbName_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbName.CheckedChanged
If Me.rbName.Checked Then
Me.ListBox1.DisplayMember = "NAME"
End If
End Sub
Private Sub rbAge_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbAge.CheckedChanged
If Me.rbAge.Checked Then
Me.ListBox1.DisplayMember = "AGE"
End If
End Sub
End Class
==========================================
i hope this will help you
WV John
tenx guys, i think i can manage from here,things started to make sense now..
regrds
-mel-
FernandoAlvarez
if you check out the link in my previous post, you will find all the answers..
Sucsess