473,698 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Focus on UserControl

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

Jul 20 '07 #1
2 9578
On 20 Jul, 12:32, Abhishek <luckyabhis...@ gmail.comwrote:
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
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_Le ave(object sender, System.EventArg s e)
{
listView1.BackC olor = Color.White;
}
private void UserControl1_En ter(object sender, System.EventArg s e)
{
listView1.BackC olor = Color.Aqua;
listView1.TopIt em.Selected = true;
}

Jul 20 '07 #2
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)(User Control1.FindCo ntrol("ListBox1 ")).Focus;
This is not exact syntac but you might have got an idea.
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Abhishek" wrote:
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

Jul 20 '07 #3

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

Similar topics

3
8001
by: Daisy | last post by:
I've started writing a listview, which currently draws my list to a pane, and onclick, works out which row you've clicked on, from the co-ordinates of the mouse, sets the .Selected property to the index of the item in my list, and onpaint, I draw this with a selected box over it. It's dawned on me, that this "list", being just text written to the pane, won't be able to recieve focus, and therefore, there's probably a better way of doing...
0
1412
by: Thorbjørn Jørgensen | last post by:
Hi I have a custom winform control based on UserControl. On this control I create some other controls in runtime. Tehse other controls contains RichTextBoxes. When I run the application I think my base usercontrol has the focus because I can control scrolling my using the mouse wheel. If i click on one of the RichTextControls it gets focus and I can edit text. But when I click on the base usersontrol again focus is still on the...
2
14648
by: Jesper | last post by:
Hi, I'm showing a usercontrol containing a textbox on the screen by clicking a notifyIcon in the taskpane. I use textBox.Focus() to set the focus for the texbox, and I also get a blinking text cursor in the textbox. However. I have to click on the usercontrol before it gets the input so that I can type text in the textbox. I would really much like to be able to wirte in the textbox immediately after clicking the notify icon. I've...
2
2010
by: Jesper | last post by:
Last week I posted this for the first time. However, I didn't get any useable solution to my problem. I'm very keen on getting this problem solved, so please excuse me for trying again. I'll try to be a little more precise. I have an app running (minimized) and without showing itself on the task bar. It puts an icon in the task pane (next to the clock), and when I click this icon, a message handler is invoked and creates a new usercontrol...
0
1173
by: BluDog | last post by:
Hi I have a vustom usercontrol that reacts by changing the background color when it receivess focus. However if i subsequently add another control to the usercontrol, that child control receives the focus rather than the usercontrol. I can understand why this is, i was wondering if there is any way to force the parent control to have the focus rather than the child control? Cheers
5
8716
by: Tosch | last post by:
I have a usercontrol with a label, a textbox, a treeview, a grid and a couple of checkboxes. The usercontrol is hosted on a form together with a cancel and a accept button. This form is used to search records in a database. On several forms in my application I show (modal) this form to search records. Everytime I show the form I want the focus to be on the textbox on the usercontrol. This works the first time I display the form. But...
2
5356
by: milund | last post by:
Hi, I am in the process of writing a custom control. In the OnMouseDown method I call this.Focus() to enable the control to receive keystrokes in OnKeyDown(). My control is hosted in a MDI form. Originally my control inherited from UserControl, but then the call to this.Focus() returned false and no keypresses were received. The I changed it to inherit from Control and everything works as expected.
3
2436
by: zacks | last post by:
I am working on an application that has a UI that supports multiuple functions by means of a group of "plug ins". Each plugin is a class library. Each plugin contains a User Control that defines the controls for that plugin's main form. The UI has a PictureBox control that is nothing but a contain to add the UserControl from the selected plugin, so that when the user selects a plugin, the main form changes appearance to the UserControl in...
2
2391
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello experts, I posted a disturbing question in here: http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.dotnet.languages.csharp&mid=dedc665f-91c0-4fa4-a103-a98a6808759c But no one have answered it. Is not clear? or maybe it a Framework bug? Please help.
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.