I'm trying to programatically set the Tag value of each Textbox and
combobox in my form to databinding field value (like:
CustomerFirstName ) so i can utilize it for filtering purpose.
Does anybody knows how to grab the value from databinding property? I
can see the property through property explorer under Data Bindings ->
Text which will have some value like: "BindingSourceName -
ActualFieldName" (which explain my code below why i have to perform
string processing to split the ActualFieldName).
Or if you have a better solution for this issue, please let me know.
Thanks
Below is my code:
Protected Friend Sub FormatControls(ByRef frm As Form)
Dim ControlType As String
For Each ctl As Control In frm.Controls
ControlType = ctl.GetType.ToString
Debug.Print(ControlType & " - " & ctl.Name)
If ControlType = "System.Windows.Forms.TextBox" Then
ctl.Tag = Mid(ctl.DataBindings.Item("Text").ToString,
InStr(1, ctl.DataBindings.Item("Text").ToString, "-",
CompareMethod.Text))
'Note: the above code fails
ElseIf ControlType = "System.Windows.Forms.ComboBox" Then
....
End If
Next
End Sub