|
Monin D. wrote: i want to set user off, when he is inactive.
Wait for the user to become inactive. Light fuse - get away. Should explode in 5 seconds.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I have one instance of Printdocument for Grid and one for Chart. I want to show these two print documents in a single Print Preview dialog box. Any ideas how to do using C#?
Thanks
kumar
|
|
|
|
|
I have not done this, but I guess it is not hard to do.
I assume there is a single page of grid and a single page of chart, and you want
to combine them on a single page.
I further assume the grid and chart each are paintable on screen; rather than doing
it in the PaintHandler directly, I would provide an indirection, something like:
private void XXX_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
XXX_Painter(e.Graphics, 0, 0, Width, Height);
}
private void XXX_Painter(Graphics g, int x, int y, int width, int height) {
// normal paint actions
}
so the actual painting is handled in a method that accepts 4 ints (or one rect) to
indicate the painting bounds. For screen painting inside a panel, the origin would be 0,0
and the size would be Width,Height of the panel itself.
Now the printdoc:
- in the printDoc constructor, attach a PrintPage handler (as always):
PrintPage+=new PrintPageEventHandler(PrintDoc_PrintPage);
- in the PrintPageEventHandler, call both XXX_Painter methods, each with an
appropriate set of x,y,width,height values
- optionally do some more g.DrawString() to annotate the graphics.
Hope this is helpfull.
Luc Pattyn
|
|
|
|
|
Thanks for the early reply. But my problem is, for Grid i am using thirdparty GridPrintDocument instance, which formats the grid as-is(including the image and other stuff) and gives output to Print or PrintPreview dialog.
And on the other hand for Chart I am using PrintDocument of System.Drawing.Printing . These work fine if i invoke Print Preview dialog separately for Grid and Chart.
I already did as you suggested but the problem is, it is removing the format of the Grid(image of the Grid), which i used to get using thirdparty GridPrintDocument instance, when single instance Print Preview is invoked for both Grid and Chart. And just shows the data in the grid as plain text.
Say for example i want to display two pages in a Print Preview dialog, one for Grid - same like the image i used to get using thirdparty GridPrintDocument instance and second page is Chart from normal System.Drawing.Printing's PrintDocument class.
Is there any way? Hope you got my point.
Thanks
Santosh
|
|
|
|
|
I see two more possibilities
I now assume the two existing halfs (grid and chart) each provide their own OnPrintPage handler.
1. with fake PrintPageEventArgs
As said before, provide a PrinPageHandler; in it:
- create a new PrintPageEventArgs based on the PrintPageEventArgs you get as an input,
but with modified PageBounds
- call grid.OnPrintPage
- do similar for chart
2. with bitmaps
As said before, provide a PrinPageHandler; in it:
- create a bitmap with the size of your print page (from PrintPageEventArgs)
- create a graphics from that bitmap (Graphics.FromImage)
- pass that graphics plus original PrintPageEventArgs to grid.OnPrintPage, so now
the grid is in your bitmap (rather than on paper)
- do similar for chart
- now on the original graphics (from PrintPageEventArgs) draw the first grid's bitmap
with g.DrawImage and appropriate bounds; this puts it on paper
- similar for chart
drawback for method 2. is scale reduction may not be optimal, since graf/chart now
have first been bitmapped, then scaled
You would have to experiment with these to see what it gives...
Luc Pattyn
|
|
|
|
|
sorry Luc, somehow i could not able to come-up to desired results. If possible can me give me a sample project?
Thanks
Santosh
|
|
|
|
|
As I said before, I never did such a thing; I only have very simple print code.
Luc Pattyn
|
|
|
|
|
hmmm... i guess it may not work as desired. I have totally two different types of PrintDocuments with different format capabilities, which need to get merged into single PrintPreviewDialog.
Thanks for your time and explanation
|
|
|
|
|
Hi,
looking around some more on CodeProject I found this article[^] that fits rather well in my last suggestion. I did not study the details but
I suggest you give it a try.
Regards,
Luc Pattyn
|
|
|
|
|
Which version of .NET Framework are you using ?
Luc Pattyn
|
|
|
|
|
sorry for late reply i am using .Net 2.0
Thanks
kumar
|
|
|
|
|
hi
i want to use iframe tag and set src to one htm file that have picture, but when i use this tag,pictures is not appeare in my webpage,but when i use htm file in browser, it show pictures. where is the problem and how to show full my htm file(with images) in ?
my code is : <code><iframe id="ifr1" src="myHtmfile.htm"></iframe></code>
<b>Note : the images folder already exist in my project.</b>
Thanks
|
|
|
|
|
Why are you reposting this? I asked you to post your code on the other instance of this question.
|
|
|
|
|
i posted my code in my question. can't see it ?
|
|
|
|
|
|
Hi All. I am using 3 tier Architecture for my application. The problem is that I am stuck while showing values in dropdownlist. On the page load event, I have written :
dsTemplate ds = ((dsTemplate)obj.GetTemplateName());
DropDownList1.DataSource = ds;
this.DropDownList1.DataBind();
In Dataset, I have just one column "ABC". In Dropdownlist, I want to show the values from that Dataset. Please help me in this regard.
|
|
|
|
|
Hi,
I think you just need to set the DisplayMember property.
DD
|
|
|
|
|
fahiemulleh wrote: DropDownList1
Please tell me this is not what it's called
fahiemulleh wrote: In Dataset, I have just one column "ABC".
You mean in the first datatable in the dataset ? I think you should make ds.Tables[0] the data source. Then set the DisplayMember to be "ABC" ( I think that's what it's called )
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
So I'm reading infomation from a text file. It will have two values, and I will supply a third. I don't know how to define the variable since I don't know how many lines will be in the text file, but I do know that the arrays within the main array will have three values. So I was thinking along the lines of.
string[,3] StrAr;
or
string[3,] StrAr;
Just to get it defined, but that didn't work. I'm new still to C#, since it is not my primary language, and the one I have a background on only seems to work in the program I learned it in (Lisp through AutoCAD).
Any help/comments is/are appreciated. Thanks in advance.
Tim
|
|
|
|
|
I guess if you only know one of the two amounts needed, don't put either one. This appears to be working right now, will see if it works for the final project.
string[,] StrAr;
If this is wrong, please let me know. Thanks.
Tim
|
|
|
|
|
Not quite sure what you are trying but here goes the basics....
Single Array
str[] strArry = new string[3]; //Number of items
Double Array
str[,] strArry=new string[4,3]; //4 Rows 3 Columns
Not too sure about anything past this, but it would be an additional ','.
The problem you are having is the 3 in the brackets.
The trick here is that an array size has to be declared when initialized, as it cannot be set dynamically, so that is where you are going to have your largest problem.
Hope this helps to get you going in the right direction.
|
|
|
|
|
Yea, I think I have a problem. The way I want to do it doesn't seem to want to work. I see that there is a method of the file class that will read all the lines to a string array. If I use that, then I will know the length, but then I'm reading the information twice, which will be slower.
I will still look for other ways. Thanks for the hints.
Tim
|
|
|
|
|
Could you explain more of what you are trying to do. There are other options for collections besides arrays,maybe a combination of them would work.
|
|
|
|
|
What I have is a csv file that has the names of my drawings, and the revision level they are at in the repository. I want to take that file and fill in a dialog box with the information for it, and the drawing. I can get the current level from the drawing, I have code for that already. Then if the revision level of the drawing needs to be updated (long story, happens alot) then I can pick it in the dialog box, type what the new revision should be, and have it update the drawing.
I'm thinking of having it as a list view, with details shown in the dialog, so all the items will be on one line, and have the options of headers.
Where I'm stuck at is, trying to create an way to have a list/array nested in another list/array that will fill out my dialog box. I don't know how long the main lis/array will be, but the sub list/array will only be three items.
Hope that explains it a little more clearer. Thanks for helping.
Tim
|
|
|
|
|
You could declare a simple class or struct that encapsulates the three values and afterwards use a generic List of this class or struct. The folowing examples uses no useful names and of course the instance fields should be made accessible by using properties.
class Values
{
public string one;
public string two;
public string three;
public Values(string one, string two, string three)
{
this.one = one;
this.two = two;
this.three = three;
}
}
List<Values> list = new List<Values>();
By the way, the encapsulation of the values furthermore allows them by name which increases readability of the code.
"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 www.troschuetz.de
|
|
|
|