|
It depends on what you filled the ArrayList with. Do you want to print Strings?
//get printer settings
PrintDialog dlg = new PrintDialog();
dlg.Document = new PrintDocument();
dlg.Document.PrintPage += new PrintPageEventHandler( YourPrintMethod );
if(dlg.ShowDialog() == DialogResult.OK){
//start printing
dlg.Document.Print();
}
private void YourPrintMethod(object sender, PrintPageEventArgs e){
//loop through the array and print the objects
foreach(object obj in yourList){
e.Graphics.DrawString(...); //draw the object
}
}
|
|
|
|
|
Hello Corinna,
thank you for your help. Yes, i want print strings.
What do you mean with the three dots in
e.Graphics.DrawString(...); ???
Regards,
Peter
|
|
|
|
|
Graphics.DrawString is overloaded, there can be different parameter lists.
This is the easiest one:
SolidBrush brush = new SolidBrush(Color.black);
int verticalPosition = 0;
foreach(String s in yourList){
verticalPosition += this.Font.Height + 5;
e.Graphics.DrawString(s, this.Font, brush, 10, verticalPosition);
}
|
|
|
|
|
Hi Corinna,
thank you very much, this works fine.
Regards,
Peter
|
|
|
|
|
i am a C++ coder who recently made the conversion to C# (with which i am very pleased)
and yes i get it the list and and array list and all of that stuff is under System.Collections but i want to know if there is anway to make them return anything other than object
for instance if i have a multi level vector... er arraylist how can i make it so that i can say:
fu[i].bar[j].symbol = 6;
ok its not a real example but it is something that i would like to be able to do
i played with the get type function since it will return something's original type (before casting to say object) but it requiers a ';' after it so that didn't work (example of what i hoped would work ...
get {return (array_name[index].getType())[index];}
...)
but anyway if anyone has ideas feel free to share
Hope is denial of reality
-Raistlin Majere
Your ticket to the future is always blank
-Vash, Trigun
Once the picture is crumpled up it can't be perfect again
-Forgotten, Linkin Park
|
|
|
|
|
vylkier wrote:
but i want to know if there is anway to make them return anything other than object
Just create a new collection class inherited from CollectionBase, and set its method data types to the data type you want.
vylkier wrote:
for instance if i have a multi level vector... er arraylist how can i make it so that i can say:
fu[i].bar[j].symbol = 6;
ok its not a real example but it is something that i would like to be able to do
Hmm... I don't quite understand what you're trying to do here... are you wanting to be able to access the object through its own type rather than through the object type? If so, then the method above will work well for this.
vylkier wrote:
i played with the get type function since it will return something's original type (before casting to say object) but it requiers a ';' after it so that didn't work (example of what i hoped would work ...
get {return (array_name[index].getType())[index];}
...)
Hmm... that should be GetType() not getType() . Other than that, it should work, except what's that extra ')' for?
|
|
|
|
|
vylkier wrote:
but anyway if anyone has ideas feel free to share
I think what you are looking for is generics[^]. HTH
-Nick Parker
|
|
|
|
|
Is there a way to put one line of code into two lines. Say for instance I had a huge line of code and it goes way off the right of the page, is there syntax so that I could make it go to the next line.
|
|
|
|
|
Yes, try Enter
static
void
Main
()
{
System
.
Console
.
WriteLine
(
"hello"
+
" "
+
"world"
)
;
}
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
It's that easy eh,just wasn't sure. Thanks!
|
|
|
|
|
Well, in C# the end of the statement is signaled with a semicolon, so you should be able to span a statement across multiple lines. Can you show an example of a huge line?
|
|
|
|
|
in visual studio you can use "Word wrap" under "tools, options, text editor, all langs, general"
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
I wrote a class that i can essential use any where for any of my Inet enabled applications. It serialize's/compresses/encrypts objects and sends them over a net work were it will rebuild it and return the object. it works great but my problem is, i am writing a Chat/File sharing application..it works fine...but i love to criticize my own code and think of how i can make it more efficient, but my lack of experience in developing internet applications and data packets to send is really leaving me stumped. Could anyone help me and point me in the write direction ? i want the system to be as Secure as possible despite the fact that the objects are already encrypt. Anyways thanks for baring with me here...
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
If it Serializes, Compresses, Encrypts and Sends an Object over a network... then it should be 4 different classes
|
|
|
|
|
it is,..encryption / compression namespaces/classes (rsa,tdes,rc2) and a listener class and a recieving class. I just dont know what type of object to send. I want my program to be secure as in...the use is notifyed that someone wants to send a list of there files, I want the other user (requester) to recieve a encryption key that only they can use to encrypt those files. i have that working and all but i was wondering if there were any examples anywhere on how other people accomplish such a thing ?
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
Do you mind if I ask why you aren't using .NET Remoting?
When I can talk about 64 bit processors and attract girls with my computer not my car, I'll come out of the closet. Until that time...I'm like "What's the ENTER key?"
-Hockey on being a geek
|
|
|
|
|
Well i found from school that using .net remoting can do the samething but i want the raw power of sockets. knowing who is connect when/where/there IP, i assume you can write this into all of your objects and do the same with remoting, but why re-invent the wheel ? and for some reason even though i spent alot of time with remoting in school i seem to beable to use Asyncronous Sockets alot easier, they just make sense to me. And i have alot of power on how i recieve the objects, for example..in my recieving callback i have a stream write the recieved bytes to a file so it doesnt hog up my memory while it waits to download all of the object. This saved alot of memory because sending files encapslated in a class are very large, my socket recieves every connection and give it a unique output and saves the reieved bytes to that output. The unqiue output dir is saved in my state object in my recieve callback and i just reuse that same state object the next time around. Once the object is fully downloaded i move on and decrypt the saved bytes, decompress / reserialize, and the other user recieved it fine. Deep down inside the remoting calls uses sockets as well...although the remoting classes are more user friendly and by all means not dumbed down at all. (it also generates the sockets for you on the fly...which is awesome)
Jesse M.
The Code Project Is Your Friend...
|
|
|
|
|
I've read up on Relection.Emit and its uses and am amazed at the flexability. But, I'm wondering if it will do more. First, I declare Dynamic Assembly using the current running assembly. I can now add members to the assembly and even switch out a method body using the MethodRental class! But, is it possible to remove members from an assembly or class? What about adding or changing members to an exising member in the assembly? Is this in any way possible, or would the entire assembly or module have to be created from scratch?
|
|
|
|
|
I reckon you have just about reach the limits of Reflection.Emit. MS has a project called the CCI (Common Compiler Infrastructure) but it is not public and they couldnt tell me when it would be.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
CCI is a Microsoft Research thing rather than a MS Corporate thing. Here's a powerpoint presentation about it. I'm fairly certain this library has be shared with the P7 folk working on other various compilers for the .NET platform.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
|
Very tantalizing, but quite a ways before it's generally available. I'm guessing that's what CCI has morphed into.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Please be kind if this is a foolish question or has been discussed ad nauseum, but I can't find it and I don't get it.
As a dyed-in-the-wool C++/MFC programmer, I now have to start usign C#, but of course new programs I write still have to interact with existing C++/MFC programs. The existing C++/MFC programs communicate with each other through Windows messages (mostly WM_USER + xxx, but also sometimes just sending a WM_CLOSE to close each other). They ALSO communicate internally to a given process among threads by using PostMessage() and PostThreadMessage() with user-defined messages.
So, to my questions:
1) Is it true, as I've read in several places now, that the only/best way for a C# application to receive a Windows message is by overriding WinProc? That seems hideous.
2) Is it true, as I've also read, that the only way for a C# application to send a Windows message to another application is by P/Invoke of SendMessage()?
3) Finally, for the communication between threads or windows of a given process. I realize that I can call functions back and forth, use delegates, or whatever, but (pardon my ignorance), that seems very synchronous and painful compared with being able to call PostMessage() or PostThreadMessage() and not have to wait for the receiver to process the message. Is there a better way?
Thanks for any advice.
|
|
|
|
|
larrywph wrote:
1) Is it true, as I've read in several places now, that the only/best way for a C# application to receive a Windows message is by overriding WinProc? That seems hideous.
From what I've done of Windows Programming the answer is yes. Why does this seem hideous to you? Overriding a function seems fairly clean.
larrywph wrote:
2) Is it true, as I've also read, that the only way for a C# application to send a Windows message to another application is by P/Invoke of SendMessage()?
seems like it
larrywph wrote:
3) Finally, for the communication between threads or windows of a given process. I realize that I can call functions back and forth, use delegates, or whatever, but (pardon my ignorance), that seems very synchronous and painful compared with being able to call PostMessage() or PostThreadMessage() and not have to wait for the receiver to process the message. Is there a better way?
Not exactly sure what you're going for here. Perhaps you can provide an example so we can better understand your problem
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
I'm calling a DLL method that has an LPTSTR parameter which may come back with embedded NULLs. After calling the method, I need to parse this parameter and extract the individual "words" into a string array:
[DllImport("myDll")]<br />
public static extern void GetMyWords(StringBuilder result, int size);<br />
<br />
public string[] GetWords()<br />
{<br />
StringBuilder sb = new StringBuilder(1000);<br />
GetMyWords(sb, 1000);<br />
return sb.ToString().Split(new char[] {'\0'});<br />
}
The problem is that the result is somehow truncated after the first word. What should I do to prevent this from happening?
Thanks!
Alvaro
Can I ask you a question?
|
|
|
|