?
Solved

using 2 fields as a listbox display member

Posted on 2011-05-12
4
Medium Priority
?
563 Views
Last Modified: 2012-05-11
I have:
lstDept.DataSource = ReportHelper.GetDepartments
        lstDept.DisplayMember = "DepartmentID"
        lstDept.ValueMember = "DepartmentID"

Thsi works fine.

Is there a way of using the two fields as the display though so say:
lstDept.DisplayMember = "DepartmentID" & " - " & "Department"
0
Comment
Question by:scm0sml
  • 2
4 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 35747310
you have to do it in your SQL query
0
 

Author Comment

by:scm0sml
ID: 35747680
Its not really an option for me so does that mean the answer is no this can't be done?
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 1000 total points
ID: 35747961
no from the DisplayMember itself.

can you add a computedColumn to your dataTable?
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 1000 total points
ID: 35748955
What is .GetDepartments returning? If its a datatable then change your code to this

Dim dTable As DataTable = ReportHelper.GetDepartments
dTable.Columns.Add("Display", GetType(String), "DepartmentID + ' - ' + Department")
lstDept.DataSource = dTable
IstDept.DisplayMember = "Display"
lstDept.ValueMember = "DepartmentID"
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question