473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Mulit-Column Databound Listbox

Hello:

Does anyone know how I can create a multi-column listbox in VB.Net
(Windows)...I am using VS.Net 2003.

If there is another control available that can be databound with multiple
columns, I would be interested in looking into that as well.

Here is the code I have (it cannot display multiple columns)...

Dim strSQL_Connect As String
Dim strSQL As String

strSQL_Connect = "Persist Security Info=False;User ID=sa;Initial
Catalog=Citywide;Data Source=(local)"

Dim conDatabase As New
System.Data.SqlClient.SqlConnection(strSQL_Connect )
conDatabase.Open()
Dim proLocation As New
System.Data.SqlClient.SqlCommand("proFindFileNames ", conDatabase)
proLocation.CommandType = System.Data.CommandType.StoredProcedure
proLocation.Parameters.Add("@OrderBy1",
System.Data.SqlDbType.VarChar, 50).Value = "templist.Files"
proLocation.Parameters.Add("@OrderBy2",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy3",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy4",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy5",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy6",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy7",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@Company",
System.Data.SqlDbType.VarChar, 50).Value = "1"

Dim adpDatabase As New SqlClient.SqlDataAdapter(proLocation)
Dim dstDatabase As New DataSet
adpDatabase.Fill(dstDatabase)
Me.lstRECORDS.DataSource = dstDatabase.Tables(0)
Me.lstRECORDS.ValueMember = "fldAIM_ID"

Thank you!
May 9 '07 #1
6 6644
Hi Justin,

Instead of a listbox, try using a listview, manually populating the list, or
a grid control with data binding.

http://www.codeguru.com/vb/controls/...cle.php/c3979/
Robin

"Justin" <Ju****@discussions.microsoft.comwrote in message
news:4F**********************************@microsof t.com...
Hello:

Does anyone know how I can create a multi-column listbox in VB.Net
(Windows)...I am using VS.Net 2003.

If there is another control available that can be databound with multiple
columns, I would be interested in looking into that as well.

Here is the code I have (it cannot display multiple columns)...

Dim strSQL_Connect As String
Dim strSQL As String

strSQL_Connect = "Persist Security Info=False;User ID=sa;Initial
Catalog=Citywide;Data Source=(local)"

Dim conDatabase As New
System.Data.SqlClient.SqlConnection(strSQL_Connect )
conDatabase.Open()
Dim proLocation As New
System.Data.SqlClient.SqlCommand("proFindFileNames ", conDatabase)
proLocation.CommandType = System.Data.CommandType.StoredProcedure
proLocation.Parameters.Add("@OrderBy1",
System.Data.SqlDbType.VarChar, 50).Value = "templist.Files"
proLocation.Parameters.Add("@OrderBy2",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy3",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy4",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy5",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy6",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy7",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@Company",
System.Data.SqlDbType.VarChar, 50).Value = "1"

Dim adpDatabase As New SqlClient.SqlDataAdapter(proLocation)
Dim dstDatabase As New DataSet
adpDatabase.Fill(dstDatabase)
Me.lstRECORDS.DataSource = dstDatabase.Tables(0)
Me.lstRECORDS.ValueMember = "fldAIM_ID"

Thank you!

May 9 '07 #2
Hi Robin,

Thank you...I just figured that out...took a while though.

I have a new question though...do you know how I can get a assign text to a
control within my Windows Form when grabbing the name (not the tab index) of
the control programmatically at run-time?

Here is my code so far...

Dim item As ListViewItem
Dim strCOL As String
Dim strVAL As String
Dim i As Integer

If lstRECORDS.SelectedItems.Count 0 Then
For i = 1 To Me.lstRECORDS.Columns.Count - 1
strVAL =
Convert.ToString(lstRECORDS.SelectedItems(0).SubIt ems(i).Text)
strCOL = Me.lstRECORDS.Columns(i).Text
Me.Controls.Item(strCOL).Text = strVAL
Next
End If

"Robin Tucker" wrote:
Hi Justin,

Instead of a listbox, try using a listview, manually populating the list, or
a grid control with data binding.

http://www.codeguru.com/vb/controls/...cle.php/c3979/
Robin

"Justin" <Ju****@discussions.microsoft.comwrote in message
news:4F**********************************@microsof t.com...
Hello:

Does anyone know how I can create a multi-column listbox in VB.Net
(Windows)...I am using VS.Net 2003.

If there is another control available that can be databound with multiple
columns, I would be interested in looking into that as well.

Here is the code I have (it cannot display multiple columns)...

Dim strSQL_Connect As String
Dim strSQL As String

strSQL_Connect = "Persist Security Info=False;User ID=sa;Initial
Catalog=Citywide;Data Source=(local)"

Dim conDatabase As New
System.Data.SqlClient.SqlConnection(strSQL_Connect )
conDatabase.Open()
Dim proLocation As New
System.Data.SqlClient.SqlCommand("proFindFileNames ", conDatabase)
proLocation.CommandType = System.Data.CommandType.StoredProcedure
proLocation.Parameters.Add("@OrderBy1",
System.Data.SqlDbType.VarChar, 50).Value = "templist.Files"
proLocation.Parameters.Add("@OrderBy2",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy3",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy4",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy5",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy6",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy7",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@Company",
System.Data.SqlDbType.VarChar, 50).Value = "1"

Dim adpDatabase As New SqlClient.SqlDataAdapter(proLocation)
Dim dstDatabase As New DataSet
adpDatabase.Fill(dstDatabase)
Me.lstRECORDS.DataSource = dstDatabase.Tables(0)
Me.lstRECORDS.ValueMember = "fldAIM_ID"

Thank you!


May 9 '07 #3
Justin,

Using a datagrid where the cell header and the column header is made
invisible is the same as a multicolumn listbox.

Cor

"Justin" <Ju****@discussions.microsoft.comschreef in bericht
news:4F**********************************@microsof t.com...
Hello:

Does anyone know how I can create a multi-column listbox in VB.Net
(Windows)...I am using VS.Net 2003.

If there is another control available that can be databound with multiple
columns, I would be interested in looking into that as well.

Here is the code I have (it cannot display multiple columns)...

Dim strSQL_Connect As String
Dim strSQL As String

strSQL_Connect = "Persist Security Info=False;User ID=sa;Initial
Catalog=Citywide;Data Source=(local)"

Dim conDatabase As New
System.Data.SqlClient.SqlConnection(strSQL_Connect )
conDatabase.Open()
Dim proLocation As New
System.Data.SqlClient.SqlCommand("proFindFileNames ", conDatabase)
proLocation.CommandType = System.Data.CommandType.StoredProcedure
proLocation.Parameters.Add("@OrderBy1",
System.Data.SqlDbType.VarChar, 50).Value = "templist.Files"
proLocation.Parameters.Add("@OrderBy2",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy3",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy4",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy5",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy6",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@OrderBy7",
System.Data.SqlDbType.VarChar, 50).Value = ""
proLocation.Parameters.Add("@Company",
System.Data.SqlDbType.VarChar, 50).Value = "1"

Dim adpDatabase As New SqlClient.SqlDataAdapter(proLocation)
Dim dstDatabase As New DataSet
adpDatabase.Fill(dstDatabase)
Me.lstRECORDS.DataSource = dstDatabase.Tables(0)
Me.lstRECORDS.ValueMember = "fldAIM_ID"

Thank you!

May 10 '07 #4

Yes that looks about right. Are you getting an error in that section of
code?
Robin
May 10 '07 #5
Hi Robin/Cor:

I was able to figure out a solution for this, but I'm not sure it is the
best solution...for now, I'm willing to work with it (b/c it does work),
unless you know of something that works more efficiently.

I actually threw my code into a public module in order to limit
redundancy...so, it looks a little different now...the problem I was running
into was with the line "Me.Controls.Item(strCOL).text = strVAL"...apparently
you cannot use the name of the control when using the Controls.Item
property...I wish there was a way I could. My work-around is to cycle
through all the controls on the form to find the one who's name matches
strCOL.

Here is my new code...

If strListBox.SelectedItems.Count 0 Then
For i = 1 To strListBox.Columns.Count - 1
strVAL =
Convert.ToString(strListBox.SelectedItems(0).SubIt ems(i).Text)
strCOL = strListBox.Columns(i).Text
For Each ctl In strForm.Controls
If ctl.Name = strCOL Then
ctl.Text = strVAL
End If
Next
Next
End If

Thank you for your help!

"Robin Tucker" wrote:
>
Yes that looks about right. Are you getting an error in that section of
code?
Robin
May 10 '07 #6
justin.

When you use the Itm your control is in fact not a really "databound"
control. It is an extra possibility.
(Althouhg you can bind object to it with mulitple columns)

By using the datasource it becomes a complex databoud control.

Why did you not try my advice, becasue the datagrid withouth those headers
is a databound listbox.

Cor

"Justin" <Ju****@discussions.microsoft.comschreef in bericht
news:F3**********************************@microsof t.com...
Hi Robin/Cor:

I was able to figure out a solution for this, but I'm not sure it is the
best solution...for now, I'm willing to work with it (b/c it does work),
unless you know of something that works more efficiently.

I actually threw my code into a public module in order to limit
redundancy...so, it looks a little different now...the problem I was
running
into was with the line "Me.Controls.Item(strCOL).text =
strVAL"...apparently
you cannot use the name of the control when using the Controls.Item
property...I wish there was a way I could. My work-around is to cycle
through all the controls on the form to find the one who's name matches
strCOL.

Here is my new code...

If strListBox.SelectedItems.Count 0 Then
For i = 1 To strListBox.Columns.Count - 1
strVAL =
Convert.ToString(strListBox.SelectedItems(0).SubIt ems(i).Text)
strCOL = strListBox.Columns(i).Text
For Each ctl In strForm.Controls
If ctl.Name = strCOL Then
ctl.Text = strVAL
End If
Next
Next
End If

Thank you for your help!

"Robin Tucker" wrote:
>>
Yes that looks about right. Are you getting an error in that section of
code?
Robin

May 12 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: sentinel | last post by:
Hi, I'm currently writing a mulit-page form app that uses a session to retain data from each form element in order for the user to jump between pages, then the final data is passed to a calculation...
0
by: Cindy Lee | last post by:
This is my code, but I can't set the value for foldernames with anything other than what's in the quotes. if I try: value=<bean:write name="_bean" property="code"/> it errors, or if I put it...
0
by: Richard Arthur | last post by:
I would like to make an executeable that has several DLLs wrapped inside of it. The DLLs are: DShowNET.dll ICE.dll Interop.DexterLib.dll Interop.SpeechLib.dll and the EXE is:
1
by: Jet Leung | last post by:
Hi: How can I control the thread? For example run a function in 3 thread or run a program in more then 1 thread?? if the speed of the program will running faster when the program is run under...
2
by: Jeronimo Bertran | last post by:
Hi, I have a database record with a very large number of fields that need to be entered so I need to write a data entry site using asp.net that will divide the fields into multiple pages. Once...
1
by: dbagirltx | last post by:
We have done some testing with mixed and forgotten results. So I'm hoping that asking here can clarify some issues for us. Right now we do one weekly warm backup. Throughout the week there are...
44
by: Kulgan | last post by:
Hi I am struggling to find definitive information on how IE 5.5, 6 and 7 handle character input (I am happy with the display of text). I have two main questions: 1. Does IE automaticall...
1
by: luftikus143 | last post by:
Hi, I have an array stocking statistical data as follow: $record = 2039; $record = 948; $record = 3621; $record = 52; $record = 575; $record = 83;
2
by: WingSiu | last post by:
I am writing a Logging util for my ASP.NET application. I am facing mulit process problem. I developed a class LogFactory, and have a method called Get_Logger to create a FileLogger, which will...
1
by: siddiq | last post by:
Hi , Do any one have solution to this problem ? I am using a display tag for pagination in my JSP page. I have a checkbox field as one of the columns. I am using displayTagWrapper class to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.