|
Thanks for the link TF
Will take a look tomorrow.
-- modified at 18:00 Wednesday 28th February, 2007
Couldn't wait
Here's what I have now, but still not working
Case "doc"
'Open WOrd
Dim newApp As Word.Application = New Word.Application
'Give it the file to open
Dim Source As Object = (OFD.FileName)
Dim Unknown As Object = Type.Missing
newApp.Documents.Open(Source, Unknown, Unknown, Unknown, Unknown, Unknown, Unknown, Unknown, Unknown, Unknown, Unknown, Unknown, Unknown, Unknown, Unknown)
'Select it all
Source.Select()
'Send it to the clipboard
Clipboard.SetDataObject(Source)
'Shut it down
newApp.Quit(Unknown, Unknown, Unknown)
'Add code here to paste it into my RTB
End Select
|
|
|
|
|
How do i make print text aligned to the centre on a page,
i have tried font.style, font. everything and cant find it!:
ive also tried adding this above: txtPrint.TextAlign = HorizontalAlignment.Center
The code i am working with is:
ev.Graphics.DrawString(txtPrint.Text, New Font("Century Gothic", 30, FontStyle.Bold), brushes.Black, 120, 120)
|
|
|
|
|
Use the MeasureString to get the width and height of the string and then calculate the center of the control or window to position your text.
Ex.
The Window's Width / 2 - TheFontWidth / 2 for the X cordinate
AND
The Window's Height / 2 - TheFontHeight / 2 for the Y cordinate
I think you can use the TextRenderer Class to to perform some more advanced drawing even in VB.NET
|
|
|
|
|
I have this code to print some text:
---
Private Sub frmPrint_Load...
txtPrint.Text = strName & ", You Got " & intPerc & "Completed on " & Date.Today
Try
Dim printdoc As New PrintDocument
AddHandler printdoc.PrintPage, AddressOf Me.printtext
printdoc.Print()
Catch ex As Exception
MessageBox.Show("There is a problem printing, please check with your teacher", _
ex.ToString())
End Try
MsgBox("Your certificate has been sent to the printer")
Me.Close()
frmResultHigh.Show()
End Sub
---
Private Sub printtext...
ev.Graphics.DrawString(txtPrin... New Font("Century Gothic", 24, FontStyle.Bold), Brushes.Black, 120, 120)
ev.HasMorePages = False
End Sub
---
Is there any way to make the lines of text on different lines on the printout, as obviously it all comes out on the same line at the moment, and is there any way to insert a pic after the text e.g.
---
Well Done
Name
Score
PICTURE
----
Cheers
|
|
|
|
|
Just add new line characters in the string where you want lines to be created. If you adding the text to a textbox it needs to have multiline set. txtPrint.text = "Line 1" & vbcrlf & "Line 2". This should create text on two different lines and drawstring should render them that way as well.
|
|
|
|
|
Cheers mate, i knew it would be something like that.
While im at it, is there any way to do 2 lines spaces without putting this:
& vbCrLf & vbCrLf
???
|
|
|
|
|
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
|
|
|
|