|
Yes, I think you have two options. "some text" & new string(vbcrlf,2) is the first. Not any better though, actually worse or create a function that wraps that up nicely for you.
Private Function newline(ByVal count As Integer) As String
Return New String(vbCrLf, count)
End Function
Now you can use: "some text" & newline(2)
|
|
|
|
|
Nice one.
One more question, last one i promise, in this code, how do i make it align to the centre, i have tried font.style, font. everything and cant find it!:
ive also tried adding this above: txtPrint.TextAlign = HorizontalAlignment.Center
ev.Graphics.DrawString(txtPrint.Text, New Font("Century Gothic", 30, FontStyle.Bold), brushes.Black, 120, 120)
|
|
|
|
|
Sorry, I'm not help there. You may want to start a new thread for that.
|
|
|
|
|
|
Hello,
I am binding a bindingsource to a datagridview and I have set the bindingsource to filter based on conditions.
However, I think that the criteria i have is too complex to put in the filter.
Is there an easier method to use.
I will try my best to explain the criteria:
AssemblyID, category, Type
Type (components, equipment, software)
Category - software (Office, DB, Anti-virus)
Category - components(memory, processor, input)
Category - equipment(printers, display, keyboard)
For example the customer could select from some combo boxes the category that want to display for that type.
I have tried doing something with the string.format e.g.
[code]
dim criteria as string = string.empty
criteria = string.format(AssemblyID = {0} AND Category = {1} AND Type = {2}",assemblyID, cboSoftware.text, cboType.text)
bindingsource.filter = criteria
dgvParts.datasource = bindingSource
[/code]
The above didn't work, so sure that filter can handle it.
Another problem I have is that i need to display many combinations for instance the user could select either software, components, or software. and the individual category for each one.
For example the user could select to find software and the category CPU, and also display components with category memory.
I think to solve this problem I would have to write many if statements, which I want to avoid doing. Is there a better more cleaner method to do this.
Many thanks for any suggestions.
Steve
|
|
|
|
|
Sorry for being dense, but could someone help?
Class A and Class B exist in the main (.exe) form.
Class A calls Class C from a .dll assembly
Class C needs to call Class B from the main form.
How can I be sure Class B remains in scope?
Thanks
|
|
|
|
|
For class C to call Class B at all, you need to hook them up via a delegate. That is your problem, nothing to do with scope.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Well, I can indeed call the Class B from Class C. However, eventually I get a message that Class B is disposed, which makes me think it has gone out of scope. I guess I'm missing something.
thanks
|
|
|
|
|
Let me explain how I’m doing it. I first initialize the assembly which contains Class B from Class A:
Sub b1()
The sub in the assembly:
Class B
Dim host as object
Sub b1(byval host as object)
Me.host = host
End sub
End Class
Then I call sub C1 which is in class C in the main:
host.C1()
Maybe this isn’t right.
|
|
|
|
|
How does class C call class B ? If it has an instance of B, then it won't be disposed. If it's a member of the main form, it shouldn't be disposed.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Class C is not in the main form... it's in a secondary form in the main .exe
I first initialize the assembly (which contains Class B) from Class A:
Sub b1()
This is Class B with its initializing sub:
Class B
Dim host as object
Sub b1(byval host as object)
Me.host = host
End sub
End Class
Then I call sub C1 which is in class C in the main .exe
host.C1()
Maybe this isn’t right, but I'm not sure what's wrong
thanks
|
|
|
|
|
This looks convoluted. Passing objects like this is always bad, you should use delegates.
Looks like the assembly is not a member variable, that's the cause of your main problem.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have a form with a datagrid, a textbox and 3 buttons.
BtnAdd - Adds a new event to the database
BtnSave - Saves to the database
BtnUpdate - Refreshes it and shows the updated version in the datagrid
My table only has an ID number and name - type Number and Text, but it wont write to the database for me, can someone show me way to do this please??
|
|
|
|
|
I'm trying to write some code that creates a picture box at a certain location when a user clicks a button. I am using this statement to initialize the picturebox:
Dim blip As Bitmap
blip = New Bitmap(filename of bitmap goes here)
Dim blipcase As New PictureBox
blipcase.Image = blip
and this statement to place the picturebox:
Dim Theta As Double = (Point.Y * PI) / 180
Dim location As New Point
location.X = (225 + ((Cos(Theta) * (30 * Point.X)) - 5))
location.Y = (225 + ((Sin(Theta) * (30 * Point.X)) - 5))
blipcase.Location = location
(Point is a system.drawing.point that contains the polar coordinates of the point)
Now, during a break in the program, I can see that location contains the right coordinates. However, I cannot get the picturebox to appear. So I do not think it is the location part that is wrong, but the initialization that is wrong. Can anyone else see something that I might be missing?
|
|
|
|
|
You didn't add the new PictureBox to your Form's Controls collection:
Dim blipcase As New PictureBox()
Me.Controls.Add(blipcase)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you, that worked great!
|
|
|
|
|
Dear Techies
i have an xml file
<bookstore>
<book genre="autobiography" publicationdate="1981" isbn="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin
<author>
<first-name>Benjamin
<last-name>Franklin
<price>8.99
<book genre="novel" publicationdate="1967" isbn="0-201-63361-2">
<title>The Confidence Man
<author>
<first-name>Herman
<last-name>Melville
<price>11.99
<book genre="philosophy" publicationdate="1991" isbn="1-861001-57-6">
<title>The Gorgias
<author>
<first-name>Sidas
<last-name>Plato
<price>9.99
**************************
I have a form that has textboxes and buttons like move first,last next previus to navigate thru xml and show the contents of the xml
the problems: when ever iterate thru loop i'm getting a loop of
"book" and value= "all attributes values concatenated"
i wanna know the to iterate each and every node of of the above xml file
Thanks in advance
btn_first code as follows...
Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
Dim xmldoc As XPathDocument = New XPathDocument("c:\books.xml")
Dim nav As XPathNavigator = xmldoc.CreateNavigator()
Dim itr As XPath.XPathNodeIterator = nav.Select("/bookstore")
Try
nav.MoveToRoot()
nav.MoveToFirstChild()
Do While nav.MoveToNext()
If nav.NodeType = XPathNodeType.Element Then
If nav.HasChildren = True Then
nav.MoveToFirstChild()
Do While nav.MoveToNext()
System.Diagnostics.Debug.WriteLine(nav.Name + " : " + nav.Value)
Loop
End If
End If
Loop
Catch ex As XPathException
MsgBox("The Error XPathException: " & ex.Message)
Catch ex As Xml.XmlException
MsgBox("The Error Xml : " & ex.Message)
End Try
End Sub
End Class
|
|
|
|
|
Hello All,
I'm trying to retreive the menu that Windows Explorer displays when you cascade menus. Here's a link to a screen shot of the menu I mean.
http://img72.imageshack.us/my.php?image=foldermenuor5.jpg
I'm fairly new to vb.net and programming in general. I'm trying to make a little launcher program just to test myself.
Thanks
Benedict
|
|
|
|
|
suppose i have 3 forms wid one button on form1 and two on form2...
wen m clickin button1 on form 1 m gettin form 2.
by coding
dim a as new form2
a.show()
same can be done on clicking button2 on form 2..
nw wen m at form 2 i wanna get back to form1 by clickin button 3 on form2...
hw can i do that....??
thanks.
-- modified at 4:12 Sunday 25th February, 2007
|
|
|
|
|
Actually you have given answer to your question. If you are going to click Button3 on Form 2 to get back to Form1, just hide form2 and show form1
a.hide()
Dim F1 as new Form1
F1.Show()
What a curious mind needs to discover or penetrate a knowledge is noting else than a pin-hole.
|
|
|
|
|
its not workin ...
please check it out..
i suppose u have suggested as:
in class form1
for Button1:
dim a as new form2
a.show
for button2
a.hide()
dim f1 as new form1
f1.show()
button3:
f1.hide() or a.hide()
dim f2 as new form 3
f2.show
|
|
|
|
|
That is how you have described the problem "nw wen m at form 2 i wanna get back to form1 by clickin button 3 on form2". However you are trying to open a new form (FORM3) not Form1 in your given example above.
Sorry but I am little bit confused...
button3:
a.hide() 'a is Form2
dim f1 as new form 1
f1.show()
What a curious mind needs to discover or penetrate a knowledge is noting else than a pin-hole.
|
|
|
|
|
yeah it looks like u rnot gettin mah problem....
m sendin u the full procedure..
if possible please send me the code.....i will be highly oblodged
start:
i have form 1 having button1
on clickin it i'll get form 2
now form 2 has two butons 1 and 2
button1(for back to the form 1)
button2(for proceeding to form 3)
now form 3 will again have 2 buttons
one for form2 and one for form 4....
END
thanks
|
|
|
|
|
I'd try to help, but I can't read this. I suggest English classes.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Well I decided to test it and it is working fine... I have included codes for both FORM1 and FORM2 below
'Use this code form1
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Dim F2 As New Form2
F2.Show()
End Sub
End Class
'Use this code for Form2
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Dim F1 As New Form1
F1.Show()
End Sub
End Class
I hope that helps...
What a curious mind needs to discover or penetrate a knowledge is noting else than a pin-hole.
|
|
|
|