Solved

Multi column vb.net listbox

Posted on 2016-07-25
5
82 Views
Last Modified: 2016-07-25
I have a form see attached, I would like the bottom listbox to show other columns from the stored procedure but not sure how

currently the listbox is populated with one column

   Private Sub CBCWSelectedItems_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CBCWSelectedItems.SelectedIndexChanged
        Dim selectedIndex As Integer
        selectedIndex = CBCWSelectedItems.SelectedIndex
        Dim selectedItem As Object
        selectedItem = CBCWSelectedItems.SelectedItem
        'MessageBox.Show("Selected Item Text: " & selectedItem.ToString() & Microsoft.VisualBasic.Constants.vbCrLf &
        '                "Index: " & selectedIndex.ToString())
        ListMatrix.DataSource = GetMatrixData(selectedItem.ToString()).AsEnumerable().Select(Function(r) r.Field(Of String)("Word")).ToList()

    End Sub

Open in new window




the SP does this
o
      SELECT [dbo].[TblWords].Word, [ClientName],[StrFull]
      FROM [dbo].TblWords
      WHERE [word]= 'f18' and [StrFull] like 'f18'+N'%'
      GROUP BY [Word], [ClientName],[StrFull]
      ORDER BY [Word]
ee.JPG
ee2.JPG
0
Comment
Question by:PeterBaileyUk
  • 3
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
Deepak Lakkad earned 500 total points
ID: 41727175
Hi,

ListBox control has MultiColumn Property. Which will show values of one field in multiple columns (Horizontal Columns).

But, If you want to show multiple column, you have to use DataGridView or ListView control.




- Deepak Lakkad
0
 

Author Comment

by:PeterBaileyUk
ID: 41727393
how do i implement that in my code
0
 
LVL 11

Expert Comment

by:Deepak Lakkad
ID: 41727416
Hi,

Can you please explain, what do you want to do with multi columns?


- Deepak Lakkad
0
 

Author Comment

by:PeterBaileyUk
ID: 41727422
I experimented and did this

DataGridView1.DataSource = GetMatrixData("F18")

works fine
0
 
LVL 11

Expert Comment

by:Deepak Lakkad
ID: 41727423
Good
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

864 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now