|
|
|
this is the code i used
PrintDocument pd=new PrintDocument();
pd.DefaultPageSettings.PaperSize= // don't know what to put here
chad
|
|
|
|
|
Set it to a new instance of the PaperSize , like so:
PrintDocument pd = new PrintDocument();
pd.DefaultPageSettings.PaperSize = new PaperSize("Legal", 8500, 14000); You can also get supported paper sizes from the printer by getting the PrinterSettings in a number of ways and then enumerating through the PaperSizes collection property.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok here is my code listing but it dose not print on legal paper is sayes manual feed plain letter on my printer
public void printpages()
{
pages=cnt;
pd.PrintPage += new inting.PrintPageEventHandler .printDocument1_PrintPage);
pd.DocumentName = "Imaging";
pd.DefaultPageSettings.PaperSize = new PaperSize("Legal", 8500, 14000);
if (pd.PrinterSettings.IsValid)
{
pd.Print();
}
private void printDocument1_PrintPage(object sender,System.Drawing.Printing.PrintPageEventArgs e)
{
System.IO.FileStream fs ; //create a filestream to open the image
fs= new FileStream("c:\\temp\\test.tiff",System.IO.FileMode.Open,System.IO.FileAccess.Read);
Image newImage = Image.FromStream(fs);
Rectangle destRect = new Rectangle( 1, 1,1000,1000);
e.Graphics.DrawImage(newImage, destRect);
fs.Close();
}
chad
|
|
|
|
|
Does your printer even support legal paper? As I mentioned before, get the PrinterSettings for your paper and enumerate the PaperSizes collection property.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm still finding my feet in the new .NET world, wanting to learn the best practises rather than just using old C++ techniques.
I'm looking for the best way for displaying a list of data records and allow double-click to launch a seperate form, passing in the record that has been selected.
In MFC, I use a ListViewCtrl and fill it with data from a recordset.
What is the best way to do this in C#.
A data-bound ListView control seemed the best way, but that doesn't seem possible in C#. Or is the DataGrid the way it should be done in C#.
I only want to display the data in a columned list, with no editing - possibly may want to have a different background colour on individual rows.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
You can always data-bind the ListView though there are no properties or functionality to do this for you like there is for the DataGrid . You can make either one work, however.
With the DataGrid , you could handle the DoubleClick event. In that handler, get the CurrentRowIndex and use that to get the DataRow in your data source. If you bind against a DataView instead, be sure to get the DataRowView with that index in order to get the row. Then just invoke whatever action you want using the data from that row.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
You can always data-bind the ListView though there are no properties or functionality to do this for you like there is for the DataGrid. You can make either one work, however.
Thanks,
Being a lazy kind of guy, I've been looking for a ListView control that already has the data-binding code implemented. Beyond a VB.NET sample on MSDN (and a poor conversion to C# here at CP), I haven't found anything.
As you seem to be the oracle when it comes to all things C#, do you know of any code that already implements data-binding in a ListView.
I'm probably going to have to write it myself, but I can't believe nobody has done it already. (I'm equally surprised that MS didn't do it either)
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
Microsoft is doing it for .NET 2.0. They're adding data-binding to the ListView (among other things, like virtual lists and grouping) and introducing an all-new control called the DataView , which is much more powerful and flexible than the DataGrid . In fact, IIRC, the DataGrid isn't even added to VS.NET 2005's toolbox by default.
There's no easy way to bind the ListView , but you can use the same tactics as the DataGrid . If the DataSource property you'd add to your own ListView derivative implements IListSource , you get the IList . If it implements IList , you simply use that. Then just enumerate that and do a little checking to see if you're enumerating simple objects or DataRow s. You can use that to bind columns.
You could go a step further (albeit a pretty big step) and create your own column handlers that allow you to specify mapping names. The best way to see how this works is to use ildasm.exe from the .NET Framework SDK to see how the DataGrid works.
Consider this, though: after you've finished you're essentially created a DataGrid . You may as well use that until you can upgrade your codebase to .NET 2.0 which should go beta later this summer presumably since it's slated to be released in Q1 or Q2 of 2005.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
Consider this, though: after you've finished you're essentially created a DataGrid.
A very good point.
Thanks for your advice, very educational. I'll take the DataGrid route for now, it should do what I need.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
I have a client calling methods in a remote server object.
The client gets data, displays it to the user, and sends updates to the server via method calls.
I am now on 1.1 Framework AND I have implemented the TypeFilterLevel=Full
We can send atomic data to the server (bool, string, etc.) but when I send my collection (marked [Serializable]) back to the server, I get the infamous Security violation error. Since I've already deployed the documented fix, what is the next step? I should be able to pass this data back to the server??!!!
______________________________
The Tao gave birth to machine language. Machine language gave birth to the assembler.
The assembler gave birth to the compiler. Now there are ten thousand languages.
Each language has its purpose, however humble. Each language expresses the Yin and Yang of software. Each language has its place within the Tao.
But do not program in COBOL if you can avoid it.
|
|
|
|
|
Many developers have been trying to figure out a way to simulate VB6 style default property in C#.
I thought of using operator overloads first. Since assignment operator doesn't overload, I used implicit to type cast.
MyClass c="Test String";
Console.WriteLine(c);
It is implemented in the following class using implicit type casting operator
class MyClass{
public static implicit operator MyClass(string s) {<br />
MyClass c=new MyClass();<br />
c.Text=s;<br />
return c;<br />
}<br />
private string _Text;<br />
public string Text{<br />
get{return _Text; }<br />
set { _Text = value; }<br />
}<br />
public override string ToString() { return Text;}<br />
}
Does someone know a simpler way?
Fakher Halim
|
|
|
|
|
That's really the only way to do it. There is no "default property" in the Common Type System (CTS), which defines how types and members are defined. So, since MyClass is not a String , you have to use an operator as you've done.
Frankly, I think the whole thing is silly. What's so hard about instantiating and assigning the Text property? Using the operator you incur one more call on the call stack.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Those VB6 developers were INSISTING on not using MyClass.Text and just assigning MyClass directly with a string , as they would do in pre-.NET days
The classical example was a Label control, where both of following mean the same:
lblEnterName.Caption = "Enter full name"<br />
lblEnterName = "Enter full name"
Fakher Halim
|
|
|
|
|
I understand what the intentions are, but this isn't VB6 - it's the .NET Framework. Change is inevitable.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
Frankly, I think the whole thing is silly. What's so hard about instantiating and assigning the Text property? Using the operator you incur one more call on the call stack.
I couldn't agree more.
|
|
|
|
|
I find it a very interesting way of simulating it.
But, frankly, I always hated this on VB, as this made the syntax very ambiguous.
Due to technical difficulties my previous signature, "I see dumb people" will be off until further notice. Too many people were thinking I was talking about them...
|
|
|
|
|
Yes, it is absolutely counter intuitive in today's strongly typed world, but sometime you need to address some irrational requirement.
Fakher Halim
|
|
|
|
|
Your method does NOT simulate default properties. It creates a new object and resets the handle, which could be disastrous from both a performance and stability standpoint. It's interesting nonetheless.
I agree with both Heath Stewart and Daniel Turini: the syntax is awful from an object-oriented perspective anyway, which is why they didn't build it in. This should be one of the times you just say "no", and you have the excellent support of not actually being able to provide the functionality!
Regards,
Jeff Varszegi
|
|
|
|
|
I agree.
It is just to illustrate how to create a new class instance out of a string. Of course it doesn't have code to add string into an existing instance, nor it has similarity to a VB6 control for that matter.
Sure it is a weird syntax -- shocking to any OO person, and that is exactly why I posted this so called VB6 compatibility possibility -- knowing the controversy.
Fakher Halim
|
|
|
|
|
I feel your pain, believe me. I have to admit that it is a fun little problem, one of those ones that always seems just out of grasp. I can't find any way to do it without some modification of the runtime.
Regards,
Jeff Varszegi
|
|
|
|
|
Hi,
I have a datagrid with 2 icon columns, I found when the screen needs to repaint, the 2 icon columns slow down the painting, it seems that loading icons is taking time, any idea about how to make loading of icons faster?
Thanks
|
|
|
|
|
For starters, if you're creating a Graphics instance yourself (probably not, but anyway...), make sure you dispose of it when finished or memory consumption will increase (call Graphics.Dispose() when finished). The same goes for the Icon . If you don't, it will take longer and longer because your memory consumption increases. Eventually you may exhaust the working memory alloc'd to your process.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi !
I will use similary method like Redim in c#
How can i do ???
dim toto(3) as string
redim preserve toto(4)
Thanks
|
|
|
|