BindingSource and Tag Property

spatterson

New member
Joined
Aug 7, 2008
Messages
2
Programming Experience
Beginner
Hi all,

I have a question on how i can set the tag property of a combo box to a element in an xml file that i have. I am binding the combo box fine with report names, but i have a report file name that i want to use also, so instead of crreating another text box and hiding it, there has to be a way to use the tag property. Here is the code that i have right now with a hidden text box.

Thanks in advance,
Scott

VB.NET:
Private xmlReportBindingSource As New BindingSource

' set the file path based on the type of app being run
If My.Computer.FileSystem.FileExists(My.Application.Info.DirectoryPath & "\xml\reports.xml") Then
    strReportFileNameToRun = My.Application.Info.DirectoryPath & "\xml\reports.xml"
    strReportFileNameToRunXSD = My.Application.Info.DirectoryPath & "\xml\reports.xsd"
Else
    strReportFileNameToRun = My.Application.Deployment.DataDirectory & "\xml\reports.xml"
    strReportFileNameToRunXSD = My.Application.Deployment.DataDirectory & "\xml\reports.xsd"
End If

ReportDataSet.ReadXmlSchema(strReportFileNameToRunXSD)
ReportDataSet.ReadXml(strReportFileNameToRun)

xmlReportBindingSource.DataSource = ReportDataSet
xmlReportBindingSource.DataMember = "CryReport"

With Me.cbxReportName
    .DataSource = xmlReportBindingSource
    .DisplayMember = "ReportDisplayName"
    .ValueMember = "ReportDisplayName"
End With

' use a hidden text box to get the report file name that we are going to run for  the report
' that the user selects
Me.txtRptFile.DataBindings.Add("Text", xmlReportBindingSource, "ReportFileName").ToString()

' test code for tag property, this doesn't work.....
'Me.cbxReportName.Tag = xmlReportBindingSource.
'Dim strTest As New TextBox()
'strTest.DataBindings.Add("Text", xmlReportBindingSource, "ReportFileName").ToString()
'Me.cbxReportName.Tag = ""
 
Looks like I was able to get it with this:

VB.NET:
Me.cbxReportName.DataBindings.Add("Tag", xmlReportBindingSource, "ReportFileName")

Scott
 
Back
Top