Solved

Multi column vb.net listbox

Posted on 2016-07-25
5
67 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

20 Experts available now in Live!

Get 1:1 Help Now