Jump to content



Recent Status Updates

View All Updates
Photo
* * * * * 1 votes

A Simple Notepad In C#

streamwriter

34 replies to this topic

#25 Nickalbokid96

Nickalbokid96

    CC Newcomer

  • Just Joined
  • PipPip
  • 22 posts

Posted 21 July 2009 - 01:08 PM

Nice tutorial, everything worked fine for me but I don't get the Word Wrap part, I'm new to C# :o

EDIT: Never mind, silly me, I read it wrong, I got it now thanks, +REP :) and by the way add a semicolon after the

txtMain.WordWrap = wordWrapMenuStripItem.Checked

, Just a little minor mistake XD

Edited by Nickalbokid96, 21 July 2009 - 07:19 PM.


#26 garrettgjb

garrettgjb

    CC Lurker

  • Just Joined
  • Pip
  • 6 posts

Posted 22 July 2009 - 07:36 AM

Thanks Kierien, I'm definitely going to do this tutorial really soon.

I have a question for you: where did you learn how to do this (looking for a good book on this kind of stuff)? I know C#, I just lack the GUI programming part of this.

Thanks.

#27 Parabola

Parabola

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 221 posts

Posted 27 July 2009 - 01:02 PM

I also seem to be having a problem with prntDoc. Here's what I've got:
[COLOR=Blue]private void[/COLOR] printPreviewToolStripMenuItem_Click([COLOR=Blue]object[/COLOR] sender, [COLOR=MediumTurquoise]EventArgs[/COLOR] e)
     {

          System.Drawing.Printing.[COLOR=MediumTurquoise]PrintDocument[/COLOR] prntDoc = [COLOR=Blue]new[/COLOR] System.Drawing.Printing.[COLOR=MediumTurquoise]PrintDocument[/COLOR]();
          [COLOR=SeaGreen]//Declare preview as a new PrintPreviewDialog[/COLOR]
          [COLOR=MediumTurquoise]PrintPreviewDialog[/COLOR] preview = [COLOR=Blue]new[/COLOR] [COLOR=MediumTurquoise]PrintPreviewDialog[/COLOR]();
          [COLOR=SeaGreen]//Declare prntDoc_PrintPage as a new EventHandler for prntDoc's Print Page[/COLOR]
          prntDoc.PrintPage += [COLOR=Blue]new[/COLOR] System.Drawing.Printing.[COLOR=MediumTurquoise]PrintPageEventHandler[/COLOR](prntDoc_PrintPage);
          [COLOR=SeaGreen]//Set the PrintPreview's Document equal to prntDoc[/COLOR]
          preview.Document = prntDoc;
          [COLOR=SeaGreen]//Show the PrintPreview Dialog[/COLOR]
          [COLOR=Blue]if[/COLOR] (preview.ShowDialog([COLOR=Blue]this[/COLOR]) == [COLOR=MediumTurquoise]DialogResult[/COLOR].OK)
          {
               [COLOR=SeaGreen]//Generate the PrintPreview[/COLOR]
               prntDoc.Print();
          }
     }
My error is:
Error 1 The name 'prntDoc_PrintPage' does not exist in the current context c:\CSharp Tutorials\Notepad\Form1.cs 71

(yes, I realize I didn't change the name of the form)

If someone could please point me in the right direction. Also, as I mentioned in my other reply today, this is my first time working with c# or VS. I have some knowledge in other languages though, and understand all the basic functions. I'm just trying to learn as much as I can as I got a job (finally) doing these kinds of things. So if you want to throw in any extra explanation, it WILL be read, I promise.
Edit:
I say first time, but I have made a form before (within past few days) that basically asks for a date frame and pulls up a report after sending a query to MySQL and another one with Microsoft SQL. However, I would like to understand and learn more about coding, not just dropping parts in and pointing them places. So really, what I'm asking is, how is this defined? how does it work? Not just what is the correct code, but actually how to fix it.
Also- note for anyone who hasn't used both- Microsoft SQL is way better.... syntax is different a little bit (having clause, aggregate functions), but it's way faster at actually running the query.

#28 476rick

476rick

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 16 March 2012 - 07:12 AM

Nice :P. but one question, if i typ txtMain in c# they underline it in red, he doesnt know that command, what to do?
plz help me:p thnx

#29 Jaffary

Jaffary

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 13 April 2012 - 07:24 PM

Very nice tutorial specially someone like me Who is begginer in C#
Thanx

#30 abbyface23

abbyface23

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 26 April 2012 - 05:34 PM

great! very useful haha...thanks

#31 TryElsIf

TryElsIf

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Others
  • Learning:Java, C#, PHP, Python, JavaScript, Others

Posted 24 July 2012 - 12:02 PM

NICE tut!

How would I add a 'Find and Replace' option to the menu?

Looked everywhere to find an answer and got nothing. So I came back here to the source.

Thank you for your help.

#32 note

note

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts
  • Programming Language:Java, C#
  • Learning:Java, C#

Posted 03 March 2013 - 04:22 AM

I also seem to be having a problem with prntDoc. Here's what I've got:

[COLOR=Blue]private void[/COLOR] printPreviewToolStripMenuItem_Click([COLOR=Blue]object[/COLOR] sender, [COLOR=MediumTurquoise]EventArgs[/COLOR] e)
     {

          System.Drawing.Printing.[COLOR=MediumTurquoise]PrintDocument[/COLOR] prntDoc = [COLOR=Blue]new[/COLOR] System.Drawing.Printing.[COLOR=MediumTurquoise]PrintDocument[/COLOR]();
          [COLOR=SeaGreen]//Declare preview as a new PrintPreviewDialog[/COLOR]
          [COLOR=MediumTurquoise]PrintPreviewDialog[/COLOR] preview = [COLOR=Blue]new[/COLOR] [COLOR=MediumTurquoise]PrintPreviewDialog[/COLOR]();
          [COLOR=SeaGreen]//Declare prntDoc_PrintPage as a new EventHandler for prntDoc's Print Page[/COLOR]
          prntDoc.PrintPage += [COLOR=Blue]new[/COLOR] System.Drawing.Printing.[COLOR=MediumTurquoise]PrintPageEventHandler[/COLOR](prntDoc_PrintPage);
          [COLOR=SeaGreen]//Set the PrintPreview's Document equal to prntDoc[/COLOR]
          preview.Document = prntDoc;
          [COLOR=SeaGreen]//Show the PrintPreview Dialog[/COLOR]
          [COLOR=Blue]if[/COLOR] (preview.ShowDialog([COLOR=Blue]this[/COLOR]) == [COLOR=MediumTurquoise]DialogResult[/COLOR].OK)
          {
               [COLOR=SeaGreen]//Generate the PrintPreview[/COLOR]
               prntDoc.Print();
          }
     }
My error is:
Error 1 The name 'prntDoc_PrintPage' does not exist in the current context c:\CSharp Tutorials\Notepad\Form1.cs 71

(yes, I realize I didn't change the name of the form)

If someone could please point me in the right direction. Also, as I mentioned in my other reply today, this is my first time working with c# or VS. I have some knowledge in other languages though, and understand all the basic functions. I'm just trying to learn as much as I can as I got a job (finally) doing these kinds of things. So if you want to throw in any extra explanation, it WILL be read, I promise.
Edit:
I say first time, but I have made a form before (within past few days) that basically asks for a date frame and pulls up a report after sending a query to MySQL and another one with Microsoft SQL. However, I would like to understand and learn more about coding, not just dropping parts in and pointing them places. So really, what I'm asking is, how is this defined? how does it work? Not just what is the correct code, but actually how to fix it.
Also- note for anyone who hasn't used both- Microsoft SQL is way better.... syntax is different a little bit (having clause, aggregate functions), but it's way faster at actually running the query.

change prntDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(prntDoc_PrintPage); to

prntDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printPreviewToolStripMenuItem_Click);



#33 MuhammedOwais

MuhammedOwais

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 17 May 2013 - 12:39 PM

this lines are giving errors. it cant read

prntDoc, txtMain



#34 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1,199 posts
  • Location:Varaždin
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 17 May 2013 - 12:48 PM

People, please learn how to use lambda expression when you are writting an event handler. Your life will be much easier.



#35 MuhammedOwais

MuhammedOwais

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted Yesterday, 11:58 PM

when i was checking  the code of notepad.. some functions was not working

e.g.1)txtMain.Clear(), (2) prntDoc.Print();

can u help me..

 









Also tagged with one or more of these keywords: streamwriter