473,748 Members | 2,602 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 9581
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
8004
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
1416
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
14656
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
2015
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
1175
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
8730
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
5360
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
2437
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
2394
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
8984
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
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
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3300
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
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
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.