Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / July 2007

Tip: Looking for answers? Try searching our database.

Focus on UserControl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Abhishek - 20 Jul 2007 12:32 GMT
Hi

I found lot of messages in this group on this issue but nothing
actually explains it quite clearly.

I've a user control with a text box and a list view.
When i set the focus to the user control i want that the list view's
1st item be selected and should look in blue. However there's no way i
can override on what should happen when Focus() is called on my user
control.

any solutions/ workaround to this problem would really help.

Thanks, Abhishek
DeveloperX - 20 Jul 2007 13:12 GMT
> Hi
>
[quoted text clipped - 10 lines]
>
> Thanks, Abhishek

Not sure what you wanted in blue, the listview or the selected item,
so I did the listview. It's the Enter and leave events you're
interested in.

private void UserControl1_Leave(object sender, System.EventArgs e)
{
    listView1.BackColor = Color.White;
}
private void UserControl1_Enter(object sender, System.EventArgs e)
{
    listView1.BackColor = Color.Aqua;
    listView1.TopItem.Selected =  true;
}
Manish Bafna - 20 Jul 2007 13:16 GMT
Hi,
Although i am not sure but you can try this.User FindControl method of
usercontrol and getreference to listbox or for that matter any other control
residing inside UserControl and then call focus method of that control.For
example something like this:
((ListBox)(UserControl1.FindControl("ListBox1")).Focus;
This is not exact syntac but you might have got an idea.
Signature

Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

> Hi
>
[quoted text clipped - 10 lines]
>
> Thanks, Abhishek

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.