Hello,
Your approach is correct, however since you didn't post the complete source
I can't tell you where the problem is.
I wrote a small sample to reproduce the wanted behavior, and it worked for
me. I created a user control with a panel (Visible set to False), and a Rich
Text Box. In the InitializeCompo nent() method of the user control I added
the event handlers for GotFocus and LostFocus:
this.richTextBo x1.LostFocus += new
System.EventHan dler(this.richT extBox1_LostFoc us);
this.richTextBo x1.GotFocus += new
System.EventHan dler(this.richT extBox1_GotFocu s);
And this is the implementation of the event handlers:
private void richTextBox1_Go tFocus(object sender, System.EventArg s e)
{
this.panel1.Vis ible = true;
}
private void richTextBox1_Lo stFocus(object sender, System.EventArg s e)
{
this.panel1.Vis ible = false;
}
I noticed that in your sample code you use a property to show and hide the
panel. Your problem may be there.
HTH,
Gabriele
"Karuppasam y" <Ka************ *******@isoftpl c.com> wrote in message
news:OW******** ******@TK2MSFTN GP12.phx.gbl...
Hi
I have created a User Control Containing a Panel and Rich Text Box. The
Panel
contains some other controls used for formatting the Text entered in the
Rich Text Box.
My Requirement is that The Panel has to be visible only when the User
Control got Focus and the Panel should not be shown to user when the User
Control lost its focus.
I have used the Following code, but its not working
this.GotFocus += new
System.EventHan dler(this.iCDCR ichTextSection_ GotFocus);
this.LostFocus += new System.EventHan dler(this.iCDCR ichTextSection_
LostFocus);
private void iCDCRichTextSec tion_ GotFocus (object sender,
System.EventArg s e)
{
this.IsControlP anelVisible = true;
}
private void iCDCRichTextSec tion_LostFocus (object sender,
System.EventArg s e)
{
this.IsControlP anelVisible = fasle;
}
why? What is the problem with this code?
Waiting for your reply.
Thanks and Regards
Karuppasamy Natarajan