Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
AnswerRe: crystal report Pin
Pete O'Hanlon15-Feb-12 5:54
mvePete O'Hanlon15-Feb-12 5:54 
AnswerRe: crystal report Pin
thatraja15-Feb-12 19:21
professionalthatraja15-Feb-12 19:21 
QuestionConsole Application In C# For Fetching Data From Live Website Pin
Muhammad Anwar Ul Haq Islam15-Feb-12 2:41
Muhammad Anwar Ul Haq Islam15-Feb-12 2:41 
QuestionDrawing Text on Panel Pin
Danzy8315-Feb-12 0:39
Danzy8315-Feb-12 0:39 
AnswerRe: Drawing Text on Panel Pin
Pete O'Hanlon15-Feb-12 1:14
mvePete O'Hanlon15-Feb-12 1:14 
GeneralRe: Drawing Text on Panel Pin
Danzy8315-Feb-12 2:05
Danzy8315-Feb-12 2:05 
GeneralRe: Drawing Text on Panel Pin
Dave Kreskowiak15-Feb-12 3:55
mveDave Kreskowiak15-Feb-12 3:55 
AnswerRe: Drawing Text on Panel Pin
Wayne Gaylard15-Feb-12 1:22
professionalWayne Gaylard15-Feb-12 1:22 
In actual fact the text is getting drawn, but every time the panel is repainted it is going to clear it out (and this will happen as soon as the form is loaded). You say you want to do this outside the Paint event, but this is where this sort of thing should be handled. You should just call the panel's Invalidate method every time the text is updated. Something like this:-
C#
string text;

        public Form1()
        {
            InitializeComponent();
            text = "No problem drawing in paint method!";
            panel.Invalidate();
        }

        private void panel_Paint(object sender, PaintEventArgs e)
        {
            Graphics grfx = e.Graphics;
            grfx.DrawString(text, panel.Font, Brushes.Black, 50, 50);
            grfx.Dispose();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            text = "Changed with the click of a button !";
            panel.Invalidate();
        }


Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

AnswerRe: Drawing Text on Panel Pin
BobJanova15-Feb-12 2:02
BobJanova15-Feb-12 2:02 
GeneralRe: Drawing Text on Panel Pin
Danzy8315-Feb-12 2:10
Danzy8315-Feb-12 2:10 
GeneralRe: Drawing Text on Panel Pin
Pete O'Hanlon15-Feb-12 2:25
mvePete O'Hanlon15-Feb-12 2:25 
GeneralRe: Drawing Text on Panel Pin
BillWoodruff18-Feb-12 1:05
professionalBillWoodruff18-Feb-12 1:05 
AnswerRe: Drawing Text on Panel Pin
Montasser Ben Ouhida2-Mar-12 4:30
Montasser Ben Ouhida2-Mar-12 4:30 
QuestionHow to create method extensions but inject into them with IoC Pin
Gizz14-Feb-12 23:08
Gizz14-Feb-12 23:08 
AnswerRe: How to create method extensions but inject into them with IoC Pin
BobJanova14-Feb-12 23:24
BobJanova14-Feb-12 23:24 
GeneralRe: How to create method extensions but inject into them with IoC Pin
Gizz15-Feb-12 0:16
Gizz15-Feb-12 0:16 
GeneralRe: How to create method extensions but inject into them with IoC Pin
BobJanova15-Feb-12 0:38
BobJanova15-Feb-12 0:38 
GeneralRe: How to create method extensions but inject into them with IoC Pin
Gizz15-Feb-12 1:41
Gizz15-Feb-12 1:41 
GeneralRe: How to create method extensions but inject into them with IoC Pin
BobJanova15-Feb-12 1:58
BobJanova15-Feb-12 1:58 
QuestionGive me some Suggestions for Make a Editor like Word Pin
Marlai14-Feb-12 21:15
Marlai14-Feb-12 21:15 
AnswerRe: Give me some Suggestions for Make a Editor like Word Pin
thatraja14-Feb-12 21:36
professionalthatraja14-Feb-12 21:36 
Questionpso(particle swarm optimization) Pin
nasrin6614-Feb-12 21:01
nasrin6614-Feb-12 21:01 
Questioncapturing outward traffic Pin
saneehaAamir14-Feb-12 19:14
saneehaAamir14-Feb-12 19:14 
AnswerRe: capturing outward traffic Pin
Keith Barrow14-Feb-12 21:52
professionalKeith Barrow14-Feb-12 21:52 
QuestionAbout Reflecting and generics Pin
PozzaVecia14-Feb-12 11:06
PozzaVecia14-Feb-12 11:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.