473,385 Members | 1,267 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

User Control

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.EventHandler(this.iCDCRichTextSection_GotFo cus);

this.LostFocus += new System.EventHandler(this.iCDCRichTextSection_
LostFocus);
private void iCDCRichTextSection_ GotFocus (object sender, System.EventArgs
e)
{
this.IsControlPanelVisible = true;
}

private void iCDCRichTextSection_LostFocus (object sender, System.EventArgs
e)
{
this.IsControlPanelVisible = fasle;
}
why? What is the problem with this code?
Waiting for your reply.

Thanks and Regards
Karuppasamy Natarajan
Jul 19 '05 #1
2 4534
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 InitializeComponent() method of the user control I added
the event handlers for GotFocus and LostFocus:

this.richTextBox1.LostFocus += new
System.EventHandler(this.richTextBox1_LostFocus);
this.richTextBox1.GotFocus += new
System.EventHandler(this.richTextBox1_GotFocus);

And this is the implementation of the event handlers:

private void richTextBox1_GotFocus(object sender, System.EventArgs e)
{
this.panel1.Visible = true;
}

private void richTextBox1_LostFocus(object sender, System.EventArgs e)
{
this.panel1.Visible = 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
"Karuppasamy" <Ka*******************@isoftplc.com> wrote in message
news:OW**************@TK2MSFTNGP12.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.EventHandler(this.iCDCRichTextSection_GotFo cus);
this.LostFocus += new System.EventHandler(this.iCDCRichTextSection_
LostFocus);
private void iCDCRichTextSection_ GotFocus (object sender, System.EventArgs e)
{
this.IsControlPanelVisible = true;
}

private void iCDCRichTextSection_LostFocus (object sender, System.EventArgs e)
{
this.IsControlPanelVisible = fasle;
}
why? What is the problem with this code?
Waiting for your reply.

Thanks and Regards
Karuppasamy Natarajan

Jul 19 '05 #2
After further discussing the issue with Karuppasamy, I realized that to
achieve what he wanted he had to use the Enter() and Leave() events of the
UserControl.

"Gabriele G. Ponti" <gg*****@hotmail.com> wrote in message
news:uK**************@tk2msftngp13.phx.gbl...
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 InitializeComponent() method of the user control I added
the event handlers for GotFocus and LostFocus:

this.richTextBox1.LostFocus += new
System.EventHandler(this.richTextBox1_LostFocus);
this.richTextBox1.GotFocus += new
System.EventHandler(this.richTextBox1_GotFocus);

And this is the implementation of the event handlers:

private void richTextBox1_GotFocus(object sender, System.EventArgs e)
{
this.panel1.Visible = true;
}

private void richTextBox1_LostFocus(object sender, System.EventArgs e)
{
this.panel1.Visible = 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
"Karuppasamy" <Ka*******************@isoftplc.com> wrote in message
news:OW**************@TK2MSFTNGP12.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.EventHandler(this.iCDCRichTextSection_GotFo cus);

this.LostFocus += new System.EventHandler(this.iCDCRichTextSection_
LostFocus);
private void iCDCRichTextSection_ GotFocus (object sender,

System.EventArgs
e)
{
this.IsControlPanelVisible = true;
}

private void iCDCRichTextSection_LostFocus (object sender,

System.EventArgs
e)
{
this.IsControlPanelVisible = fasle;
}
why? What is the problem with this code?
Waiting for your reply.

Thanks and Regards
Karuppasamy Natarajan


Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
0
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: davidr | last post by:
Hi, I have a panel that I load user Control in no problem. The problem arrises when I do a post back on one of these user controls. I have button it does a click event. In this click event I...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
3
by: Fred Chateau | last post by:
I am trying to access a user control class, for a user control that is loaded dynamically, from the containing page. I have been able to access Web controls in the user control, but so far I have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.