|
Sub pd_Printpage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
Dim linesPerPage As Single = 0
Dim yPos As Single = 0
Dim leftMargin As Single = ev.MarginBounds.Left
Dim topMargin As Single = ev.MarginBounds.Top
Dim line As String = Nothing
' STAMPA INTESTAZIONE
IntestazionediPagina(yPos, leftMargin, topMargin, ev)
count = 14 + 1
printFont = New Font("Courier New", 10, FontStyle.Regular)
' Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
' BEGIN READ FILE
Do Until EOF(Numfile)
' Print each line of the file.
If count < linesPerPage Then
FileGet(Numfile, RigoOrdine)
line = Rigo(RigoOrdine)
yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat)
count += 1
ElseIf Not line Is Nothing Then
ev.HasMorePages = True
'IntestazionediPagina(yPos, leftMargin, topMargin, ev)
Exit Sub
Else
ev.HasMorePages = False
End If
Loop
End Sub
When generates the second page the text is written on the first page
Tks
Fulvio
|
|
|
|
|
The very same PrintPage event handler gets calle donce for every page printed until the e.hasMorePages is not true.
This means that variables which track the current position of the text and also reading of the text from the file has to happen outside that event handler.
I have some articles on printing that show this being done - suggest you look at the "Printing a datagrid" one as it handles flowing over multiple pages.
|
|
|
|
|
I am creating a VB.NET windows application and am unsure at whether i should be publishing the final executeable or creating a install/deployment project.
I have tried the publish route (both to a web url and a directory) and the program installs fine. However i want to control where the exe file is sent and the publish does'nt seem to give me that.
Is this what the install/deployment route will give me?
Or is there a valid reason for using one over the other?
(Yes, i am a .NET newbie)
Regards
|
|
|
|
|
Don't repost the same question multiple times. If there's additional information you need to provide, just Modify your original post.
|
|
|
|
|
Dave Kreskowiak wrote: Don't repost the same question multiple times.
Oh gawd, another one of those
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I have a simple GUI interface that loads menus dynamically from a range of dll's/plugins.
The problem I face is one of the plugins has a lot of Dependencies and needs to be executed with its own application path to be able to fucntion correctly.
Is there a way I can load it into my GUI but set its base paths for loading assemblies etc to another path.
A brief idea of what i want to achive.
C:\program files\My App\Centralize Gui\Gui.exe
C:\program files\My App\App1\App1Gui.dll
C:\program files\My App\App2\App2Gui.dll
Currently Gui.exe uses Activator.CreateInstance to dynamically load App1Gui.dll which returns a predefined iGUI interface.
Public Interface Gui
Delegate Sub RebuildMenuEventHandler()
Property RebuildMenu() As Boolean
Function GenerateMenu() As System.Windows.Forms.ToolStripMenuItem
Sub AdminLevelChanged(ByVal AdminLevel As RMS.Gui.AdminLevels)
Sub LoadGui()
Sub ExitGui()
End Interface
The Gui.exe then calls LoadGui.
The LoadGui routine does a lot of stuff and has to be able to access and load objects etc from assemblies within its own folder(eg C:\program files\My App\App1).
This is where I hit the issue as it is currently running within "C:\program files\My App\Centralize Gui\" and of course fails to load any of the App1Gui.dll's dependencies.
My gut feeling is I need to do something with Appdomains so that I can get App1Gui.dll to run within its own path but I cant find any good examples on how to achieve this and I haven't managed to get any of my own attempts anywhere near working. The solution works fine if i put my GUI within the App1 folder but this is not the solution as I need to have a single GUI that can control multiple applications.
Thanks in advance for any help/pointers.
To Errrr is human, but to really foul things up requires a computer
|
|
|
|
|
I have a VB.NET windows app that i have built an exe file for. I orignally put the .exe file on the c:\ for ease of testing but the app didn't work.
It complained 'PublicKeyToken=null or one of its dependencies. The system cannot find the file specified.'
I have solved this by Publishing and installing the application, instead of just copying the exe file and config file across.
However the publish wizard gives me the option of were to publish the install to but not where the install puts the exe file.
How can i do this?
|
|
|
|
|
ClickOnce deployment does NOT give you the option of specifing where to install the application. You have to use a traditional Setup project (MSI-based) to specify the installation directory.
Also, what was the EXACT error message you got when you just did the copy of the .EXE and config file?? Did you also make sure you copied over any .DLL files that were in the Debug or Release folder??
|
|
|
|
|
Did'nt copy ALL the DLL's but only got an error message for one of the DLL's.
Anyway, i have now created a MSI install which works better.
Thanks
|
|
|
|
|
barney_1972 wrote: Did'nt copy ALL the DLL's but only got an error message for one of the DLL's.
They end up in the bin\Debug and bin\Release folders for a reason. Without them, you can expect your app to crash at some point.
|
|
|
|
|
Hi
I have developed an application using WebBrowser control under the .Net 2.0 framework which enables the user to navigate Web pages inside the form..
In this application the user visits web-sites in WebBrowser control.
Whichever sites he is visiting I am recording all sites along with PostData, Url and Frame information in the XML file.
Before navigating the following event is raised up and in that event I am saving the navigation information in XML file.
<br />
Protected Friend Sub OnNavigatingExtended(ByVal Url As String, ByVal Frame As String, ByVal Postdata As Byte(), ByVal Headers As String, ByRef Cancel As Boolean)<br />
Dim e As WebBrowserNavigatingExtendedEventArgs = New WebBrowserNavigatingExtendedEventArgs(Url, Frame, Postdata, Headers)<br />
'Save data to XML file if not in Replay mode.<br />
If recordFlag = True Then<br />
Dim xFunctions As New XMLFunctions<br />
stepNo = xFunctions.WriteRequest(stepNo, Url, Frame, e.PostdataToString(Postdata), Headers, Cancel.ToString)<br />
'This is fucntion is written in another class and it stores the information into XML file.<br />
End If<br />
<br />
RaiseEvent NavigatingExtended(Me, e)<br />
Cancel = e.Cancel<br />
End Sub<br />
But unfortunately the above event is not raised in following scenarios and because of that I am not able to store these steps in XML.
1. When user is downloading any file from the web-page displayed in the WebBrowser control.
2. If user is visiting the pages and doing steps within same page,
ie. He is navigating such that the page remains same only the data in frames of the page changes. I’ve kept option to replay the user’s visits. If user wants to see the pages he has visited then he can replay the
websites using Replay button. But for above two cases it is not displaying those steps in replay.
Please tell me what can be the remedy for these problems.
Abhishek J
|
|
|
|
|
Hi,
First code clears worksheet from previous data and excel formulas. Then retrieves data from database to excelworksheet. So far so good.
To reduse calculation from excel formulas. The formulas are created after database retreaval. Due the nature of dynamic. I can't create formulas before data is retrieved because data is not static nor goes to known place.
Excel SUM-formulas goes nice, but when inserting IF-formula exceptions begin.
Globals.Sheet3.Cells(10, 10).Value = "=IF(B28=""X"";C8/C29*D29;(B8+1)*C8)"
or
Globals.Sheet3.Cells(10, 10).Formula = "=IF(B28=""X"";C8/C29*D29;(B8+1)*C8)"
Above statement produce underlying error message.
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll
I think this is some kind of bug, but does enybody know a way to go around it?
Actually Cells(10, 10) and B28, C8 and D29 values are from variables that are calculated from data. I tried to insert any If formula to excel using VSTO2005 but result was same exception.
Pete
|
|
|
|
|
The bug is in your code. You're getting the COM exception because you're doing something that Excel doesn't like. In the Excel If function, the condition, true and false expressions must be sperated by commas, not semicolons.
|
|
|
|
|
|
I have a timer thread that calls a function with the following code:
Dim i As Integer = CType(RichTextBox1.Lines.Length / 2, Integer)
While i > 0
If RichTextBox1.InvokeRequired() Then
' Invoke the delegate.
Me.Invoke(m_RemoveLinesRichTextBoxDelegate)
Else
RichTextBox1.Lines(0).Remove(0, RichTextBox1.Lines(0).Length)
End If
i -= 1
End While
I like to remove sort of 50% of the lines in the RichTextBox
The delegate does contain the same line as if the invoke is not required, the delegate is setup fine.
The problem. Well it does not seems to remove the line. Anyone can explain me how to do it correct?
I am working with .NET 1.1
Thanks
|
|
|
|
|
strings are immutable, so string.Remove() returns a new string, it does not modify an
existing string.
Why not RichTextBox1.Lines(0)="" ?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- 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 PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
My code is like this to assign values to an integer array but i am getting an error like Object reference not set to an instance of an object...
Dim StepNumber() As Integer = Nothing
Dim Aindx As Integer = 0
ds = bl.GetStepDS(Session.Item("TestCase").ToString())
For Each record As DataRow In ds.Tables(0).Rows
StepNumber(Aindx) = Aindx
StepNameList(Aindx) = record.Item(0).ToString()
Aindx = Aindx + 1
Next
Can anybody please help me how to create and use Integer array?
Thanks in advance
|
|
|
|
|
Your array is not instanciated, try
Dim StepNumber() As Integer = new integer() {}
|
|
|
|
|
kokilaB wrote: Dim StepNumber() As Integer = Nothing
You declared an unbound array of Integers, then set it to Nothing. Bad idea.
You also cannot assign values to an unbound array. The array has to have bounds in order to use it.
ds = bl.GetStepDS(Session.Item("TestCase").ToString())
If ds.Tables.Count > 0 Then
If ds.Tables(0).Rows > 0 Then
Dim StepNumber(ds.Tables(0).Rows.Count - 1) As Integer
For Aindex As Integer = 0 to ds.Tables(0).Rows.Count - 1
StepNumber(Aindex) = Aindex
StepNameList(Aindex) = record.Item(0).ToString()
Next
'
' Do whatever you need to save and/or return the array here, because
' it won't exist outside this nested If statement.
'
End If
End If
|
|
|
|
|
Hi,
Kindly see the codes below:
On the next button I call ShowReconcileStatement.
In ShowReconcileStatement I call GetGridTotal.
When I call the GetGridTotal, Before it enters the procedure, I get an exception as : Object reference not set to an instance of an object. The code where the exception occurs I have underlined.
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Try
tcBankReco.SelectedIndex = 1
ShowReconcileStatement()
Catch ex As Exception
End Try
End Sub
Private Sub ShowReconcileStatement()
Try
Dim i As Integer
Dim bnkDep As Double = 0
Dim bnkWith As Double = 0
bnkWith = GetGridTotal(dgtmp, dgtmp.Cols(WITHDRAWLS).Index)
bnkDep = GetGridTotal(dgtmp, dgtmp.Cols(DEPOSITS).Index)
Catch ex As Exception
End Try
End Sub
Private Function GetGridTotal(ByVal dg As C1.Win.C1FlexGrid.C1FlexGrid, ByVal col As Int16) As Double
Try
With dg
Dim rg As CellRange = .GetCellRange(1, col, dg.Rows.Count - 1, col)
Dim agg As String = .Aggregate(AggregateEnum.Sum, rg)
Return CDbl(agg)
End With
Catch ex As Exception
Return 0
ShowMessage(ex.Message, 30)
Finally
End Try
End Function
Please suggest..
Thanks and Regards,
|
|
|
|
|
Your dgtmp FlexGrid is not instantiated.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
"Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"
|
|
|
|
|
Dot Net Jantu wrote: bnkWith = GetGridTotal(dgtmp, dgtmp.Cols(WITHDRAWLS).Index)
Your code is assuming that dgtmp.Cols(WITHDRAWLS) is returning an object. If it doesn't return an object, meaning that it returns Nothing , calling the Index property on it will throw this exception.
|
|
|
|
|
Hi All
how to get the DateTime value of a remote mahine.
By
George Garvasis
|
|
|
|
|
I don't know if there is a library for this but using command prompt may be a way.
Use command prompt:
net time \\Computename > C:\temp\time.txt
and parse time.txt to get the time.
For other options use:
net time /?
Hard way but it may do the work
Pete
|
|
|
|
|
any suggestions how to solve my problem in viewing my crystal report in vb.net 2003 :
an unhandled exception of type 'System.ExecutionEngineException' occured in crdb_adoplus.dll
thanks in advance!!!
jyn
|
|
|
|