|
The examples in the MSDN documentation don't work? I hardly doubt that, because they have been tested and have been in public sight for several years now. I'm sure someone wouldn't noticed and alerted Microsoft, especially since they have such an easy documentation bug link at the bottom!
And as I have sound countless times - post WHY enumerating the PaperSizes didn't work! What exceptions where thrown, if any? It is possible that the printer does not support that paper size! It is, after all, a rather large piece of paper - if the printer tray doesn't support it, it will use the default!
So, write a simple application that enumerates and displays the valid PaperSizes that it supports and see, or debug your code and check the state of objects after lines that don't seem to have an effect.
If you keep asking the same question, you'll get the same answer - so provide us with more details and what exceptions - if any - are being thrown, or example snippets of code showing that you are trying what we have written and where the exception is being thrown. I assure you that enumerating PrinterSettings.PaperSizes works! Tell us why it's not working for you!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
This is the example I am trying. I am using an Epson LX-300 printer. The enumeration worked, i forgot to tell you that. But my initial question was that I need to create a custom form, and print using that paper size. In this example, I created manually, in Server Properties, in the printer & faxes form, and created the "MIPAPEL" form. When selecting the papersize I use the last element in the enumeration, and it printed the size I wanted, but I created it manually. If I use the new PaperSize("CUSTOM", 8.5*100, 5.5*100) it doesnt work. It seems as it is ignoring my custom size. Also, when doing this, there are no exceptions.
Just create a C# project and copy this.
-Code Start Here-
using System;
using System.Drawing.Printing;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 176);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(296, 213);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
PrintDocument pd = new PrintDocument();
string s = "";
// enumerating the valid papers
foreach( PaperSize ps in pd.PrinterSettings.PaperSizes )
{
s += ps.PaperName + "\n";
}
// show the paper sizes defined for the printer
MessageBox.Show(s);
// this is a custom paper size defined manually
// using the dialogs provided on Windows XP
pd.DefaultPageSettings.PaperSize = pd.PrinterSettings.PaperSizes[pd.PrinterSettings.PaperSizes.Count - 1];
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.QueryPageSettings += new QueryPageSettingsEventHandler(pd_QueryPageSettings);
// printing the document
pd.Print();
}
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
// printing code goes here.....
e.HasMorePages = false;
}
}
}
Carlos Eduardo Hernandez P.
|
|
|
|
|
If you created a form called "MIPAPEL" (which I guess is supposed to be "MYPAPER"), why did you pass "CUSTOM" for the name of the form in the PaperSize constructor? Try passing "MYPAPER"/"MYPAPEL" and see if that works.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I try that before sending the example and it doesnt work, The PaperSize only have one constructor, ant it ask for the name of the papaer, and the width, and height. I put the same thing and it ignores it. One of my problems is solved, because with the enumertion I could manually create the form and use it in my code. But what I need is to be able to create a new paper size, and use it. In the code I sent you, there was a mistake, the line that calls the querypagemethod take it out.
Thanks.
Carlos Eduardo Hernandez P.
|
|
|
|
|
Look here: http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=PrintDocument+PaperSize+custom[^].
It does work. You could be right about the server forms configured on the system, but the PageSetupDialog doesn't seem to mind. If you solved the problem of printing an A3 form by enumerating the PaperSizes like I said a while back, great. If you're trying to print something else customized, it's possible the printer (or maybe even the print server) might not support it.
There were some examples of setting custom paper sizes in the google link I gave you. If they don't work for you, either you have a botched .NET installation (which I doubt, because many other things would be wrong), or your printer has problems or limitations. I have a Lexmark myself and I am not particular crazy about it (what can I say, it was free).
Have you tried a different printer?
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks, I found what I was looking. But if you have read it, you have noticed that what I was asking cannot be done with C#, not completly. There is an example on how to add the form using c++ code, and then with that form, use it in c# to print the custom size. So I assume the custom size option using the papersize constructor only works on Windows 98 or before.
Carlos Eduardo Hernandez P.
|
|
|
|
|
integrasoft wrote:
So I assume the custom size option using the papersize constructor only works on Windows 98 or before.
That's probably a safe assumption. Just P/Invoke the method(s) you need to save from having to write a native DLL.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is there a way to turn on the standard context menu for a RichTextBox. (Copy/Cut/Paste/etc)
It shows up by default in a standard TextBox.
Thanks,
-Luther
|
|
|
|
|
There isn't one. It's not hard to provide, though - just create a ContextMenu with those menu items. The RichTextBox (inherited from TextBoxBase ) already has methods for Cut , Copy , and Paste .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Sounds easy enough.
Thanks,
-Luther
|
|
|
|
|
Hii All,
I wanna know how can i send mail thru my pc without using any email client.
i tried using SMTPMail object. in that i specified the SmtpServer as "localhost". On doing so all my mails are delivered into "c:\Inetpub\mailroot\Queue\" directory.
Now i want to know how d i send these mails to xyz@yahoo.com or at hotmail address.
Please someone help me.
Tushar
|
|
|
|
|
Um, do you know C#? If so, I can give you some refrences...
Framework SMTP Class:
System.Web.Mail Namespace[^]
CodeProject Examples:
SNTP Client in C#[^]
Sending Mail Using C# via SMTP[^]
But really; Before looking at all that, you should read this...
The SMTP Specification[^]
I havn't read this particular one, but I did read the POP3 specification. It gave me a much clearer understanding of what's going on. So, do that.
And always remember and never forget... SEARCH GOOGLE. There are tons of examples on the net too, with lots of 3rd party components also.
I hope this helps... I'm not sure if I under stood you correctly... "...without using any email client." With out a client at all, with out Outlook, a console window, service? i'm confused...
/\ |_ E X E GG
|
|
|
|
|
|
You have to setup your SMTP Virtual Server in the Internet Information Manager snap-in (in your Administrative Tools in your Control Panel) to forward mail accordingly. Otherwise, the server doesn't know where to send mail.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hii
Thanx for this.
But actually i didn't unerstand anything in this GEEK code. COuld u please tell me in detail how to configure SMTP virtual server so that i can send mails to Internet mail accounts like Yahoo and Hotmail.
|
|
|
|
|
Um, yeah, that's called a signature - it wasn't part of the message.
As I said, open Internet Information Manager and you should see your SMTP Virtual Server. Right-click and select Properties, then RTFD. There's far too much to cover in a forum. You have to understand basic SMTP implementation, but the docs will help. As always, just hit F1.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
like the title:
I use DataTable to set windows form datagrid datasource ,
i want to create a summary Row for windows form datagrid,
but i donot know how to do it?
who can give me a example using C#??
thank you very much??
|
|
|
|
|
What do you mean by summary row? You mean you wanna filter your datatable?
tablename.DefaultView.RowFilter = "filter expression";
Mazy
No sig. available now.
|
|
|
|
|
This has been asked before, and as I told the previous person, you should consider using Label controls below the DataGrid . If you have a data-bound DataGrid and programmatically add a row, you must do so to the DataGrid.DataSource , which will add the row. If you then update that data source (say, to a database or XML file), it will contain that summary row. This is hardly what you want, I assume.
So, just use some values below it. That's what we do in our application, and there are many other benefits as well. First, it separates the summary of columns making it easier to see, and it doesn't scroll or resize like a DataGrid could, thus hiding certain summations. Second, one rarely needs to summarize ALL fields (for example, how would you summarize a name field for a person, company, etc.?), so just include enough labels to summarize what you need.
To summarize columns, just enumerate the rows and keep track of what you need to, then assign that value (or whatever) to a label that shows the value (or, if you use one label for the text label and value, use String.Format or something to assign the "Label: Value", "Label=Value", or whatever format to the Label.Text property).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hi
I get everytime a Exception error shortly after successfully compiling
i just get it, when the compile mode is on release and not debug
this is the error (translated by me, orign was german):
An not controlled Exception of the type 'System.ArgumentException' occurred in system.drawing.dll.
Additional Information: false paramter used.
that's the error, even before Form1_Load can happen
the disassembly also tells me something
Adress: System.Drawing.Bitmap..ctor
and a yellow arrow is beside of the following line:
00000067 push dword ptr [ esp + 10h ]
posting the sourcecode is a very bad idea, more than 1200 lines in 5 different files and no part is highlighted when the eception occours
i hope anyone can help me with handling the error
|
|
|
|
|
beta3 wrote:
that's the error, even before Form1_Load can happen
It may happent in your InitializeComponent(),You may use some GDI+ there.
Mazy
No sig. available now.
|
|
|
|
|
thx, that was the error
and now everything is working
|
|
|
|
|
You sent some code for me. Where was the problem in your codes?
Mazy
No sig. available now.
|
|
|
|
|
there wasn't a real program, just a little mistake, because i forgot something
but i could solve it by myself
|
|
|
|
|
Hi,
Any ideas on how to exclude documentation of private and internal members
of the classes while generating docs from the "Tools|Build Comment Webpages.."
option of VS.Net?
Thanks,
Sridhar.
|
|
|
|
|