Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VB.net Listbox

Posted on 2014-10-09
18
152 Views
Last Modified: 2014-10-13
Hi Experts

I have a list box (Picture Attached) which I want to populate with data
currently it shows the supply Name only. I want to add the Supplied Date and Returned Date
The sql is in a stored procedure  (Attached)
and the Load Supply List (Attached)
when I try and add the extra fields Supply Date - (reader.getDateTime(2).tostring("dd/mm/yyyy") I get error

Too many arguments to public sub Add(key as tKey, value as tValue) I don't know where to change the setup

Also when error corrected and I add Returned Date (reader.getDateTime(3).tostring("dd/mm/yyyy") )
will this cause error if NULL if so how do I check

Thanks
ListBox.docx
Screen.png
0
Comment
Question by:Kevinfeening
  • 9
  • 9
18 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40372034
the ListView control is more appropriate. Check http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.aspx
0
 

Author Comment

by:Kevinfeening
ID: 40372043
Thanks for that but this is an inherited program and the previous developer created the controls as UiElement Components and I need to use them as they are used all through the program otherwise it would be a large change

I would like to be able to change the existing component as there are others needing the same modification
Thanks
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40372056
you can try to concatenate the multiple columns in a single string.

you can also use the MultiColumn property of the ListBox control but it is not very elegant: http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.multicolumn(v=vs.110).aspx
0
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.

 

Author Comment

by:Kevinfeening
ID: 40372072
Again thanks I tried that before and when there were more than 1 item the columns didn't line up and they also didn't line up with the Headings

Set up as

Protected Overrides Sub CreateColumns()
   Me.listview.columns.add("Employee",10, HorozontalAllignment.left)
   Me.listview.columns.add("Supply",30, HorozontalAllignment.left)
   Me.listview.columns.add("Supplied",14, HorozontalAllignment.left)
   Me.listview.columns.add("Returned",14, HorozontalAllignment.left)
end sub

Sorry
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40372157
Is this a listview or a listbox that you are using?
0
 

Author Comment

by:Kevinfeening
ID: 40372163
apologies I typed ListBox instead of ListView at the beginning
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40372602
so you are really using a ListView? That means that the first link I have provided was good.
0
 

Author Comment

by:Kevinfeening
ID: 40374239
http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.aspx
Yes it was but when I add more than 2 elements to the Listview

                Me.CategoriesList.Add(reader.GetInt32(0), reader.GetString(1), reader.GetString(2))

the reader.GetString(2) causes error
Too many arguments to public sub Add(key as tKey, value as tValue)

it works fine as
Me.CategoriesList.Add(reader.GetInt32(0), reader.GetString(1))
0
 

Author Comment

by:Kevinfeening
ID: 40374319
Hope this helps Checking his code in the Form has the following

Ths xxxxxx is replacing the company name I didn't want it displayed  

#region windows Form designer generated code

            Private withEvents mCategoriesList as xxxxxx.uiElements.Categorieslist
            Me.mCategoriesList = new xxxxxx.uiElements.Categorieslist
            Me.mTabPage.Controls.add(mCategoriesList)

            'mCategoriesList
            '
            Me.mCategoriesList.Anchor = System.Windows.Forms.AnchorStyles.None
            Me.mCategoriesList.Boat = Nothing
            Me.mCategoriesList.Location = New System.Drawing.Point(5, 502)
            Me.mCategoriesList.Name = "mBoatCategoriesList"
            Me.mCategoriesList.Size = New System.Drawing.Size(414, 95)
            Me.mCategoriesList.TabIndex = 33
            Me.mCategoriesList.Text = "ListPanel"
            Me.mCategoriesList.UseCheckBoxes = False
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40374768
is that a custom control? I don't recognize the Boat property.

Me.mCategoriesList.Boat = Nothing
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40374777
If you have a plain old listview control, this could would work

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
	ListView1.View = View.Details
	ListView1.Columns.Add("Col 1", 50, HorizontalAlignment.Left)
	ListView1.Columns.Add("Col 2", 50, HorizontalAlignment.Left)
	ListView1.Columns.Add("Col 3", 50, HorizontalAlignment.Left)

	Dim str(3) As String
	For i As Integer = 1 To 5
		str(0) = String.Format("v{0}-1", i)
		str(1) = String.Format("v{0}-2", i)
		str(2) = String.Format("v{0}-3", i)
		ListView1.Items.Add(New ListViewItem(str))
	Next
End Sub

Open in new window

0
 

Author Comment

by:Kevinfeening
ID: 40375139
Yes its a custom control and that's the problem I don't understand how to change it
from 2 columns to  3 or 4
boat=nothing if you highlight it the message is (public property boat() as XXXXX.objects.boat gets/sets the boat) which is the actual program I changed the names to employee supplies etc so the product wasn't displayed on the net

I may have to try a different approach instead of trying to copy his work
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40375619
have you tried to add your 3 values to an array of string and add the array to the items collection like my sample is showing?
0
 

Author Comment

by:Kevinfeening
ID: 40375994
Yes but when you key in the phrase - Items.Add

Items is not a member of system.collectors.generic.system.Dictionary(of integer, string)
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 40376038
since you have a custom control that nobody but you ever used, I am afraid that we can't help you!
0
 

Author Closing Comment

by:Kevinfeening
ID: 40376042
There May be no answer but the support was excellent
0
 

Author Comment

by:Kevinfeening
ID: 40376048
is there a standard form with the ability to add the options like add, delete and then Icons as shown in screen.png
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40377260
there is no standard form. You need to create a form and add a toolbar to it.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 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