473,385 Members | 1,622 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.

What use OnGotFocus?

How am I supposed to use a Control's Overridable On* Methods?
I'm obviously missing something very important about them but they
just don't seem to do anything for me :-(

I have a UserControl which contains, among other things, a TextBox.
I'm trying to override the UserControl's focus-getting behavious such
that, on calling [Control].Focus() - which is probably my problem
- the User Control /intercepts/ this and puts directly focus into the
TextBox.

I've tried handling the GotFocus Event on both the UserControl and
the TextBox, and now overriding the OnGotFocus method, but
(a) I never get focus into my TextBox and
(b) the Focus() method itself returns False, even though it and all
its "parent" controls are both Visible and Enabled.

Any suggestions gratefully received...

TIA,
Phill W.
Nov 20 '05 #1
1 1894
Something like this perhaps:

Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
myTextBox.Focus()
End Sub

Public Overrides ReadOnly Property Focused() As Boolean
Get
Return myTextBox.Focused
End Get
End Property
/claes

"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:ca**********@yarrow.open.ac.uk...
How am I supposed to use a Control's Overridable On* Methods?
I'm obviously missing something very important about them but they
just don't seem to do anything for me :-(

I have a UserControl which contains, among other things, a TextBox.
I'm trying to override the UserControl's focus-getting behavious such
that, on calling [Control].Focus() - which is probably my problem
- the User Control /intercepts/ this and puts directly focus into the
TextBox.

I've tried handling the GotFocus Event on both the UserControl and
the TextBox, and now overriding the OnGotFocus method, but
(a) I never get focus into my TextBox and
(b) the Focus() method itself returns False, even though it and all
its "parent" controls are both Visible and Enabled.

Any suggestions gratefully received...

TIA,
Phill W.

Nov 20 '05 #2

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

Similar topics

2
by: thecrow | last post by:
Alright, what the hell is going on here? In the following code, I expect the printed result to be: DEBUG: frank's last name is burns. Instead, what I get is: DEBUG: frank's last name is...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
12
by: Dario | last post by:
The following simple program behaves differently in Windows and Linux . #include <stdexcept> #include <iostream> #include <string> using namespace std; class LogicError : public logic_error {...
1
by: Mubashir Khan | last post by:
I am deriving a class from TextBox to implement a NumericBox. I am overriding OnGotFocus and OnLostFocus methods but On GotFocus is causing problems. Actually the commented lines are causing...
1
by: Richard Grene | last post by:
After upgrading to 2003 my forms OnGotFocus does not fire? Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs) Any ideas? Thanks, Richard
3
by: Gabor | last post by:
I want to capture the textbox ongotfocus event, but it is missing in the event list. I found the Enter event, but it seems doesn't work. What I'm doing wrog? Thanks in advance Gabor
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?

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.