|
I write a program to print an undee chart.The main code as follows:
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
AddHandler PrintDocument1.PrintPage, AddressOf drawpictoprinter
PrintDocument1.Print()
End Sub
Private Sub drawpictoprinter(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim pg As Graphics
pg = e.Graphics
pg.TranslateTransform(xtran, ytran) 'xtran,ytran >0
pg.ScaleTransform(xscaletran, yscaletran)
Dim j As Integer
Try
For j = 0 To rwrecord - 1 'rwrecord is the unbound of
'array redraw or ydraw
pg.DrawLine(redrawpen, xredraw(j), -yredraw(j), xredraw(j + 1), -yredraw(j + 1))
Next
Catch ex As Exception
Throw ex
Finally
pg = Nothing
GC.Collect()
End Try
End Sub
when i press button5 the first time.what do you think the output chart of printer?And the second time?The third time?....
When i do it the first time.Output chart is an undee chart that i want to be.But the second time when i do it.Two undee chart appear.and One is upper,the other is under it.The horizontal distance is xtran,The vertical distance is ytran.
I do think the focus is pg.TranslateTransform(xtran, ytran) and
pg.ScaleTransform(xscaletran, yscaletran)
I run the program step by step.what i found are:
1>when i press button5 the first time.drawpictoprinter method execute one
time
2>When i do it the second time.drawpictoprinter method execute two times
3> And so on
WHY?
Any care will be appreciated much
Best regards
ICQ:258-235-734
MSN:msnadair@hotmail.com
-- modified at 9:19 Friday 2nd June, 2006
|
|
|
|
|
codeadair wrote: AddHandler PrintDocument1.PrintPage, AddressOf drawpictoprinter
This is causing it. You are adding the event handler everytime you press your button. Either unbind (RemoveHandler) it after you have finished or make sure you bind it only once.
|
|
|
|
|
Hi,
I am trying to retreive a string between a tag in my HTML page. I can get the string if it is <td>The String is here</td>. But the problem is when it is like this <td bgcolor="#FFEFCE" width="40%" align="center">The String is here</td>, the result I may get is 'bgcolor="#FFEFCE" width="40%" align="center">The String is here'. How do I get rid of the other unwanted stuff?
Please do help me, I have been cracking my head to solve this. Thank you
J Liang
|
|
|
|
|
Have you tried using Regular Expressions, from the System.Text.RegularExpressions namespace?
There are several articles to get started with Regular Expressions here on the CodeProject. Something like the following regex might work (note I havn't checked this properly): \<td[^\>]*\>([^\<]+)\</td\>
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Thanks Ed, for replying.
I have used the Regular Expression, thanks for showing me the syntax, it works, at least now I can continue with my work.
Just one more thing, how do you guys know the formatting like "\<td[^\>]*\>([^\<]+)\</td\>" is to get whatever between <td></td> and also cut off the rest and get the string between only? I'd been searching for this 'dictionary', so that I do not need to ask around always on how to get the expressions I want.
Thanks
J Liang
|
|
|
|
|
J Liang wrote: how do you guys know the formatting
Practice and experience! It's just like another programming language, albeit with a very concise syntax, but once you know how to use it it is very powerful indeed, the only major penalty is the performance one but you can compile Regular Expressions to .NET code by using Regex.CompileToAssembly .
There are some articles here on CP as I mentioned, one is very good but I couldn't find it when I was writing the last message. Just do a search for "regular expressions", some will be related to C#, VB.NET or C++ but they all share more or less the same syntax.
Other useful sites are:
Regular-Expressions.info[^] - All information about regular expressions for different languages.
The Regulator[^] - A regular expression designer (in .NET)
RegexDesigner.NET[^] - Another regular expression designer (in .NET by Chris Sells)
RegexLib [^]- A library of useful regular expressions.
By the way if you want to extract the text, use a named group e.g. \<td[^\>]*\>(?<text>[^\<]+)\</td\> <td[^\><text>, you'll notice that the parentheses now have a name following them in the square brackets (basically the syntax for a named group is </td[^\>(?<name><name><span style="font-style: italic;">regex</span>)</name> <td[^\><name>). You can then retrieve the text that matches that group by something like the following:
</td[^\>
<td[^\><name>Regex.Match(inputString, "</name></td[^\>\<td[^\>]*\>(?<text>[^\<]+)\</td\><td[^\><name><td[^\>", RegexOptions.Compiled).Groups("text").Value</td[^\></name></td[^\> <td[^\><name><td[^\>
(Sorry if I got the syntax slightly wrong for the code but I primarily use C#). You can see that you can access one of the groups of text through it's name as specified in the regex.
Hope this helps. I actually learnt most of my regex stuff from Francesco Balena's "Programming Visual Basic .NET" book by the Microsoft Press. (Yeah, I started out with VB then moved to C#) and it's a very good general book on .NET (1.1).
</td[^\></td[^\>
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
EdLast modified: 03 June 2006 05:15:40 -- Quote
|
|
|
|
|
I don't know whether am I asking too much but when asking about this question, I have a major problem with getting data from a table. The reason I wanted to identify <td></td> is because of the columns that hold the data I wanted, the code snippet is like this:
<table border="2" cellpadding="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#808080" width="100%">
<tr>
<td width="40%" colspan="4" bgcolor="#FFEFCE" align="left">
<b>Policy No</b></td>
<td width="40%" colspan="4" align="left"> 12345678</td>
</tr>
I wanted to extract 'Policy No' and '12345678' and save it into database but there are tons of row like the above and some are not relevant to my search. I try to split them into group like those with <b></b> is the name for that row and those without it is the value to that row, but it does not work either as there are other <td></td> with value that I don't want to retreive. Example:
<td width="100%" align="right" colspan="2"><font color="green"><b>John Smith, 03/06/2006</b></font><br/><hr/></td>
The code snippet I have is from another programmer and I can't ask him to alter any thing on the page. Maybe I can get some idea from you if you don't mind, I have been cracking my head for a algorithm for 3 days now, just can't find any best idea.
Anyway, thanks for the info, Ed, and the guidance too. It's my first time using VB.NET and this Regular Expression method. I'll go through those articles you told me, need to learn thoroughly about this Regular Expression.
Regards,
J Liang
-- modified at 9:38 Saturday 3rd June, 2006
|
|
|
|
|
Hi all,
I have a ToolStripMenu in my application. I would like to change the
cusor from default to help cursor when i click on a item in the
ToolStripMenu. I was successfully able to change the cusor, but when
moved the cursor on certain items, the cursor again changes to default.
When moved away from such items, cursor changes to help cursor. I later
found that the help cursor remains unchanged for items which has help
for those items are enabled.
So when i move the help cursor to a toolstripmenu item, cursor changes
to default cursor. I would like to know how to avoid this change in
cursor when moved to toolstripmenu item as there is no property to
enable help for a toolstripmenu item.
I would appreciate your help in this regard.
Thanks,
Sugan
Chennai
|
|
|
|
|
How did you change the cursor? Have you used Cursor.Current = ... ?
|
|
|
|
|
I used the following.
Me.cursor = system.windows.forms.curosrs.help
What happens when i use this is cursor changes to a help cursor. But when this cursor hovers over components which does not support help, it changes back to default cursor. For a toolstripmenu item there is no property available in .Net 2.0 version to enable help for that component. Hence when i move the cursor over it, the cursor changes back to default cursor.
Pls help.
Thanks,
Sugan
Chennai
|
|
|
|
|
Try setting Cursor.Current = Cursors.Help instead. It changes the cursor for the whole application.
|
|
|
|
|
In fact
Cursor.Current = Cursors.Help
does not work at all.
Only Cursor = cursors.help works.
Even then, when i move the cursor to a menu item in the form, the cursor changes back to the default cursor. When i move out of the menu item, cursor changes to help cursor.
Thanks,
Sugan
Chennai
|
|
|
|
|
Is there no one who has a resolution for this issue.
I'm not getting any resply for this issue in most of the forums. Is it such a big deal to solve this???
Sugan
Chennai
|
|
|
|
|
does anybody out there now how to use the volume shadow copy service for vb.net.
i need to invoke it and then copy certain files then stop the service in win xp . please help if anybody can
|
|
|
|
|
Hi All,
Can anybody tell me what the meaning of this code snippet is?
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
In the above what this ‘<’ and ‘>’ indicates.
Thanks in advance.
Regards,
Krishnaraj
|
|
|
|
|
Hi All,
Can anybody tell me what the meaning of this code snippet is?
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
In the above what this ‘<’ and ‘>’ indicates.
Thanks in advance.
|
|
|
|
|
they specify the opening and closing declaration for an Attribute (in this case DebuggerStepThroughAttribute) which adornes the method.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
It's a metatag. there are certian tags taht handle specifics about how a class compiles and integrates into the VS Environment. for instance
<catagory()>
before a public property causes the propety to show up in the forms designer properties window. that is evidence that VS is prebuilding certian parts of an object to facilitate its WYSIWYG interfaces (like to provide intellisense on new components, custo user controls etc.) the metadata tells the environment which parts to pre-compile in this case.
Web service methods use a similar tag to indicate that teh code gen should create an XML interface and description of the method so it can be enumerated to clients and called via soap.
Think of it as Code defining Code. that is what meta means in any sense. metadata is data about or describing data. gives me a headache myself...
hope that satisifies your curiosity,
Frank
hey...slang is the vernacular for the vernacular...wow
|
|
|
|
|
Thank for giving such a good explanation.
Regards,
Krishnaraj
|
|
|
|
|
currency that can calculate with currency.
|
|
|
|
|
WTF? How about writing a proper question that we can answer?
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
Hi all,
In aspx file I have a Data grid. Of which two columns are Template columns. Both of these columns contain Label and Drop down list. On non-edit mode label will display the current information present in the DB. On clicking edit, it will change to Drop down list, giving option to make changes to that particular column value. Now list of items in the second template column drop down list must be populated on the basis of first column drop down box selection.
Eg: first column lists countries then on selecting particular country, second column must display states which belong to the selected country.
Also I have set the drop down list property AutoPostBack = True. So eah time when I change the country it sends it back o the server. But I am not getting any even handlers to handle the even triggered.
Can anybody help me out?
Thank in advance,
Regards,
Krishnaraj
|
|
|
|
|
ASP is not my specialty so I can't address the edit-mode or the postback, but for the events, the short answer is to:
create a custom control that inheirts your first Template collumn.
add a public delegate and event within it. raise the custom event on the first templatecollumns changed event.
public delegate sub delIndexChanged(sender as object, e as system.eventargs)
public event evtIndexChanged as delIndexChanged
Private thing(sender as object, e as system.eventargs) handles me.selectedindexchanged
RaiseEvent me.evtIndexChanged(sender,e)
End sub
in your mainpage (the one with the grid), Replace the template col reference with one to your custom control.
once you instantiate the grid cols, add a handler for the evtIndexChanged that points to a sub with
AddHandler MyGrid.cols(idx).evtIndexChanged , AddressOf <subname>
where <subname> has the appropo parameter list for the delegate signature.
that will fire whenever the first col changes. I would use it to gen a filterstatement for a dataview.
to fire the col directly you can just RaiseEvent Object.Event(parameters...) I think. postbacks will complicate this.
I just read somthing about the asp2.0 callback model, and they claim there are now ways to update stuff on the UI (via server side processing) without posting back on the client. you may want to look into it but as I said web isnt my area of expertise.
Hope That Helps,
FrankyT
hey...slang is the vernacular for the vernacular...wow
|
|
|
|
|
I have not tried the solution u have given. Coz most of the things u mentioned did not go into my mind. It may take some time to understand. But anyway thanks a lot for taking trouble to give me a solution.
Regards,
Krishnaraj
|
|
|
|
|
I have installed Visual Studio 6.0.
While I am opening a VB project, it is displaying only the code behind; not the user interface. While double-clicking the form in the project window, it displays the message-<The instruction at "0x004581f1" referenced memory at "0x00000000".The memory could not be read.>
& as I am clicking ok,the project is closed.
Although, a new project can be created & run properly.
Kindly help...
Padma Gahlot
|
|
|
|