|
I Figured as much for the decimal Places I just still don't know what property or even where to put it. As for the format, I don't know what property I would use or wear to put it either. Basically with these two I am stuck. Do you know the properties I would need to use and where to put them?
|
|
|
|
|
Hi shawndeprey;
The code below will correctly format the strings. The other issue you will have is that the font assign to controls by default are not monospace font meaning that each character will have a different width and therefore will never line up. What you need to do is go to the property page for the control and change the font of that control to a monospace font. One such font is Consolas. Once you have made this and the code change it will line up.
' You need two format strings one that has all text
' One that has currency values at the end.
Dim headerStr As String = "{0,-10}{1,30}"
' The C in the format string formats the number in
' currency format, $999.99, no need to add $ to string
Dim frmStr As String = "{0,-10}{1,30:C}"
Dim cust As String
Dim a, b, sum1, sum2, sum3, sum4 As Double
a = CDbl(txtHour.Text)
b = CDbl(txtPart.Text)
sum1 = a * 35
sum2 = b * 0.05
sum3 = b + sum2
sum4 = sum1 + sum3
cust = txtCust.Text
lstOutput.Items.Clear()
lstOutput.Items.Add(String.Format(headerStr, "Customer", cust))
lstOutput.Items.Add(String.Format(frmStr, "Labor Cost", sum1))
lstOutput.Items.Add(String.Format(frmStr, "Parts Cost", sum3))
lstOutput.Items.Add(String.Format(frmStr, "Total Cost", sum4))
Fernando
|
|
|
|
|
PERFECT!!! I changed to font to Courier New and presto! Thanks Bunches Fernando.
|
|
|
|
|
Not a problem, glad I was able to help.
|
|
|
|
|
|
Hi,
did you create subitem(10) before you tried to assign some text to it?
array elements need to be created before they can be operated on, same as simple objects: create first, then use.
How about ...items(5).subitems.add(something)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
First, the ListViewItem is the first column, so now you've got 10 columns left. These would be the SubItems of the ListViewItem, numbered 0 through 9, not 10.
|
|
|
|
|
Do not delete your question, after you got an answer, ffs!!
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
how does one go about attaching an image in Vb.net,more specifying its image and what data type is it when creating a table?
|
|
|
|
|
There is a very interesting tool that has a name, something like google, you should learn to use it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
ngugi wrote: how does one go about attaching an image in Vb.net
To what??
ngugi wrote: more specifying its image and what data type is it when creating a table
What table?? And what data type are you talking about? Type of what??
|
|
|
|
|
This is a bit of a Newbie question...
I am trying to write a class which adds a control to it's host, where the host could be any suitable container such as a Panel, GroupBox, or a Form.
I know I can add a control directly to a Form for example in the following way:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles MyBase.Load
Dim myControl As New SomeControl
With myControl
.Left = myLeft
.Top = myTop
.Width = myWidth
.Height = myHeight
.Visible = True
End With
Me.Controls.Add(myControl)
End Sub
But I'm having trouble doing it from within a class.
Public Class MyNewClass
.
.
.
Public Sub New(ByVal newLeft As Short, ByVal newRight As Short, ByVal newWidth As Short,_
ByVal newHeight As Short)
myLeft = newLeft
myRight = newRight
myWidth = newWidth
myHeight = newHeight
Dim myControl As New SomeControl
With myControl
.Left = myLeft
.Top = myTop
.Width = myWidth
.Height = myHeight
.Visible = True
End With
Me.Controls.Add(myControl)
End Sub
Clearly "Me" now refers to the instance of MyNewClass and not the Container or Form in which it is intended to go, so it's not going to work.
How should I do it?
Thanks in advance.
|
|
|
|
|
hi
pass a reference of the form to your class.
Public Sub New(ByVal newLeft As Short, ByVal newRight As Short, ByVal newWidth As Short,_ ByVal newHeight As Short, ByVal form As Form1)
regards
|
|
|
|
|
Your suggestion would work, but IMO the form should be adding the control not vice-versa.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
It's bad form to do what you're attempting. The child should know nothing of it's parent, nor should it modify the environment of the parent. The parent tells the child what to do, not the other way around.
Normally, the parent container would add the child controls to the form, with the child having implemented a common interface that the parent expects it to.
|
|
|
|
|
Thanks for your comments. It got me thinking about my whole approach.
With a little more reading I realised what I'm actually trying to do is create a User Control.
I can stick all the controls I want in it, and handle events from the "sender".
Problem is now solved and working fine.
|
|
|
|
|
1. Is it possible to automatically add the custom controls to the toolbox as soon as the reference is added to a project? Meaning, the user would not have to right click and add the controls in manually to the toolbox.
2. How can the developer determine which group the custom controls appear under in the toolbox? For example, can I lump all custom controls under a new group called "ABC controls" automatically when the reference is added or when the user right clicks and adds the controls in?
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
There is no method of having a control just pop into the ToolBox when you set a reference to a .DLL. You actually have to create an VSI installer package for the control (which is just a .ZIP file) to accomplish this.
You can find the quick'n'dirty explanation here[^]. The more cyptic Microsoft version can be found here[^].
|
|
|
|
|
Thanks for the links Dave.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
hi everyone!
i want to store good quality images in a database. how could i do that?
whre can i find sample code in this area?
|
|
|
|
|
Your question has nothing to do with the subject line. So I don't know if this is going to answer your question, but... This has been asked and answers thousands of times all over the web. Google results for "vb.net save image to sql database[^]"
|
|
|
|
|
how to copy the values of a textbox into the textbox of a webpage where the cursor is already positioned in the textbox of the webpage
|
|
|
|
|
What actually you want to achieve? Why you want to do this?
Your question is unclear to me.
|
|
|
|
|
Do you want tome kind of hover effect or something to happen when the focus is given to the text box?
|
|
|
|
|
the text from the form has to be pasted in the text area on the website page where the cursor already points when the website is opened
|
|
|
|