I'm creating a login where my data is stored in an XML file and I'm having an issue adding databindings to my two textboxes and a checkbox. What I'm doing is:
A) Loading a DataSet from an XML file:
B) Checking for a username/password match:
C) Then if there is a match and the user is an admin, load up my admin form:
D) In my admin_form's load event I set up a bindingsource and set all the databindings:
The issue that I'm having is that my DataGridView shows the data no problem, however my two textboxes and checkbox don't do anything at all. Take a look at the picture:
![Name: unsafe.png
Views: 90
Size: 20.2 KB]()
Am I just adding the databindings wrong? I'm expecting the txt_remove_user and txt_remove_pass to read column1 and column2 of the selected row of the datagridview.
A) Loading a DataSet from an XML file:
Code:
Private Sub CreateDatatable(ByVal path As String)
ds = New DataSet
ds.ReadXml(path)
End SubCode:
'column 0 is the ID
'column 1 is the User
'column 2 is the Pass
'column 3 checks for the admin rights
Dim dt As DataTable = ds.Tables(0)
Dim IsMatch As Boolean = False
Dim IsAdmin As Boolean = False
For i As Integer = 0 To dt.Rows.Count - 1
If dt.Rows(i)(1).ToString = user AndAlso dt.Rows(i)(2).ToString = pass Then
IsMatch = True
If dt.Rows(i)(3).ToString = "true" Then
IsAdmin = True
End If
Exit For
End If
NextCode:
If IsMatch AndAlso IsAdmin Then
'If the user is an admin
Dim admin_form As New FormAdmin
'admin_form.ds is a public DataSet
admin_form.ds = ds
admin_form.Show()Code:
Private Sub FormAdmin_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
BindingSource1.DataSource = ds.Tables(0)
DataGridView1.DataSource = BindingSource1.DataSource
txt_remove_user.DataBindings.Add("Text", BindingSource1, "User")
txt_remove_pass.DataBindings.Add("Text", BindingSource1, "Pass")
cb_remove_admin.DataBindings.Add("Checked", BindingSource1, "User")
End SubAm I just adding the databindings wrong? I'm expecting the txt_remove_user and txt_remove_pass to read column1 and column2 of the selected row of the datagridview.