|
Hint: When you do a ReadLine the stream advances.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
So, this is a StreamReader problem...? I though it had to do with the ArrayList... hmm...
/\ |_ E X E GG
|
|
|
|
|
Yes, it's the StreamReader (actually, any stream or reader), but it's not a problem. This is the behavior of any IO on every platform I'm familiar with. You read, the cursor advanced.
-----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-----
|
|
|
|
|
No! It's a logical error!
Step 1: You read a line and check if it is not "."
Step 2: You read a line and add it to the arraylist.
So you have to ask yourself one question, what happened to the string in step 1 if it wasnt "."?
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
ohhhhhhhhh.
I see, let me mess with it.
/\ |_ E X E GG
|
|
|
|
|
string feed=null;
while(feed!=".")
{
feed=(sReader.ReadLine());
retrMessage.Add(feed);
}
There it is. I hope you had fun laughing at me.
/\ |_ E X E GG
|
|
|
|
|
leppie wrote:
That code is just wrong, I'm not gonna even read the rest
- Nick Parker My Blog
|
|
|
|
|
Could anyone point me to a multiline (text of an item can be displayed on multiple lines) listview Windows Forms control?
Thanks
|
|
|
|
|
Trying searching[^] first. There's a ton of examples of this on CP alone, besides what the link above provides. It's just an owner-drawn ListView which is trivial to do. You could also google for it.
-----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, but I searched first and then asked for help.
|
|
|
|
|
Do you need a ListView or a ListBox ? The samples that are available are vastly different, and owner-draw ListBox examples are far more plentiful because they provide managed support for owner drawing, where a ListView requires that you override a hell of a lot of Windows messages and handle many different notification messages.
-----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 need a ListView control.
|
|
|
|
|
At this time, there isn't many articles on CodeProject about this. There was one, but the guy used CodeProject as a testing front for what he later turned commercial.
To know what you need to do, research the Windows Common Control ListView. There are messages and notifications that you must be familiar with. After this, you override WndProc in your ListView derivitive class and handle those notification messages. You'll probably also have to P/Invoke several methods (especially SendMessage ) and create constants that represent message ID, and several structs.
You can try googling for an example, too.
-----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-----
|
|
|
|
|
|
Carlos, just curious if you plan to continue posting your articles here, they are always full of great information and a great learning tool.
- Nick Parker My Blog
|
|
|
|
|
Hi Nick,
I would like to write a series of articles on WinFX --or Avalon, or whatever the name for new technology for writing Windows Application in Longhorn will be.
Probably, when Longhorn gets into beta and things get more well defined I will start posting some of my findings here. The new batch of technologies making a debut in Longhorn will surely keep us busy for years to come and I am certainly looking forward to sink my teeth on all the information related with the new UI model.
Regards,
Carlos.
|
|
|
|
|
True, I am looking for a free one, but I've saved your link for time when I will develop software for sale. Thanks
|
|
|
|
|
|
Thanks. I will check it out. This seems to be what I need. No source code, though.
|
|
|
|
|
The source is in the demo project.
|
|
|
|
|
Is it possible to somehow specify the text of the MessageBox buttons?
I'd very much like some "Yes to all" and "No to all" options, but the aren't many standard button titles to schoose from
|
|
|
|
|
You're probably going to have to create your own message box class.
--Colin Mackay--
|
|
|
|
|
Nope, if you use Anikrino and look at the code for MessageBox.Show, it calls the Win32 MessageBox calls, which only allow you to specify Yes, No, Cancel, Ignore, Ok, Retry.
You'll have to create your own message box form.
|
|
|
|
|
I've tried to used this article http://www.codeproject.com/csharp/CsAutomateWord.asp?target=Word to create a character sheet.
I have a CCharacter class, that contains all information about a character, and I want to generate a MS Word document with these information.
So I've created .dot document, with thinks like
Name _Name_ Age _Age_
in arrays (I've tried also without the array, directly in the text). _XXX_ is code that I will use for replacement.
Now, to the code:
// Create a Word application
Word.ApplicationClass vk_word_app = new Word.ApplicationClass();
// Open the .dot
object FileName =Directory.GetCurrentDirectory()+"\\Models\\Sheet.dot";
Word.Document vk_my_doc = vk_word_app.Documents.Open(...
// Create a new document
Word.Document vk_new_doc = vk_word_app.Documents.Add((...
// Copy the .dot into the new document
vk_my_doc.Select();
vk_word_app.Selection.Copy();
vk_new_doc.Select();
vk_word_app.Selection.PasteAndFormat(Word.WdRecoveryType.wdPasteDefault);
// close the .dot
vk_my_doc.Close( ref vk_false, ref vk_missing, ref vk_missing );
All the previous steps work. I get a new document, build from my template.
Now, I'd like to fill it with actual information. So I do this
// Select the new doc
vk_new_doc.Select();
// Define some variable
object vk_false = false;
object vk_true = true;
object vk_num = Word.WdFindWrap.wdFindStop;
object vk_find = "_Nom_";
object vk_replaceWith = Name_Familly; // This one is a member of CCharacter class
object vk_replace = Word.WdReplace.wdReplaceOne;
// Try to replace the text
vk_word_app.Selection.Find.Execute( ref vk_find,
ref vk_false, ref vk_false,
ref vk_false, ref vk_false, ref vk_false, ref vk_true,
ref vk_num, ref vk_false,
ref vk_replaceWith, ref vk_replace, ref vk_false,
ref vk_false, ref vk_false, ref vk_false );
And... it doesn't work.
I got this error:
System.Runtime.InteropServices.COMException (0x800706F7): Le relais a reçu des données incorrectes.
at Word.Find.Execute(Object& FindText, Object& MatchCase, Object& MatchWholeWord, Object& MatchWildcards, Object& MatchSoundsLike, Object& MatchAllWordForms, Object& Forward, Object& Wrap, Object& Format, Object& ReplaceWith, Object& Replace, Object& MatchKashida, Object& MatchDiacritics, Object& MatchAlefHamza, Object& MatchControl)
My form close, the word doc stays opened.
"Le relais a reçu des données incorrectes" would translate as "incorrect data received".
Any idea of a way to solve this would be greatly welcomed!
|
|
|
|
|
The form is probably closing because you're not handling the exception like you should be. Users should never see an exception thrown but should see a nice little error message without your app crashing.
As far as the COMException , I'm betting the problem is where param values should be an empty variant but you're passing a reference to false . This is not the same in the world of COM. Instead, try the following:
object empty = Missing.Value; Anywhere you need to pass an empty argument, pass a ref to empty (or whatever you call it).
Also, .NET naming conventions recommend that you don't use the hungarian notation, like putting "C" before a class name. Just consider how all the classes you use in the .NET Base Class Library (BCL) are named, as well as the methods, properties, etc. Using the same conventions is important, because anyone using your library or extending your application - and that's any language that targets the CLR like C#, VB.NET, MC++, COBOL.NET, and many others - should be consistent to avoid confusion and other hastles.
-----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-----
|
|
|
|
|