473,386 Members | 1,610 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,386 software developers and data experts.

Problem with CanFocus and SetFocus()

I am running into a problem with the CanFocus property not allowing me
to set the focus to a control. The application is a Form which has a
Panel and in the panel are a series of user controls. Each of the user
controls consist of a label and a combobox or text box which is
determined at runtime.

When the application starts, the focus should be set to the first
combobox or text box in the panel. What happens is that the appliation
will start, but the focus will be somewhere else until the user hits
the tab key. At that point, the focus will go to the first entry
control in the panel like it should.

I have gone through the documentation, and found a number of conditions
that must be true in order for a control to get the focus. I have
created a debug log to check these conditions and I get:

MySetFocus(company)
selectable = True
contained = True
Parent Visible & Enabled = True
Visible & Enabled = True
canFocus = False
Handle = 7145084
TabIndex = 0
TabStop = True
set focus = False
entry control set focus = False
entry panel contains focus = False

Other messages in this group and others have suggested that I set
TabIndex to 0 and use the ActiveControl property. Neither of these
have worked. Actually as Panel does not have ActiveControl, I set the
panel to be the active control in the Form and that did not work either.

Sep 11 '06 #1
1 8837
You could try Form.SelectNextControl() at the end of the initialisation.
A bit of a hack but it might be easier then searching for the issue for days.
Ciaran O'Donnell

"Brian" wrote:
I am running into a problem with the CanFocus property not allowing me
to set the focus to a control. The application is a Form which has a
Panel and in the panel are a series of user controls. Each of the user
controls consist of a label and a combobox or text box which is
determined at runtime.

When the application starts, the focus should be set to the first
combobox or text box in the panel. What happens is that the appliation
will start, but the focus will be somewhere else until the user hits
the tab key. At that point, the focus will go to the first entry
control in the panel like it should.

I have gone through the documentation, and found a number of conditions
that must be true in order for a control to get the focus. I have
created a debug log to check these conditions and I get:

MySetFocus(company)
selectable = True
contained = True
Parent Visible & Enabled = True
Visible & Enabled = True
canFocus = False
Handle = 7145084
TabIndex = 0
TabStop = True
set focus = False
entry control set focus = False
entry panel contains focus = False

Other messages in this group and others have suggested that I set
TabIndex to 0 and use the ActiveControl property. Neither of these
have worked. Actually as Panel does not have ActiveControl, I set the
panel to be the active control in the Form and that did not work either.

Sep 12 '06 #2

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

Similar topics

10
by: Matt Fielder | last post by:
I have developed a custom control to be used in my application. My application includes a form designer, so the control can be hosted while designmode for the control is either true or false,...
4
by: Corepaul | last post by:
I am a newbie using Access 2000. I am using the following test in the txtAlbum OnExit procedure to prevent leaving an empty text box for a required field If (IsNull(txtAlbum.Value)) Or...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers for...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
3
by: Jim Devenish | last post by:
In my application vehicles arrive and depart from a workshop. The ArrivalDate and the HandoverDate are each entered. Sometimes the person who should enter the arrival date forgets to do so. ...
1
by: Brian | last post by:
I am running into a problem with the CanFocus property not allowing me to set the focus to a control. The application is a Form which has a Panel and in the panel are a series of user controls. ...
8
by: sara | last post by:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report. Then it seems I still get the 2501 message on the Open Report...
5
agroover
by: agroover | last post by:
I can't seem to figure out how to get rid of the errors. I recieve the following error when I leave the Grade.SetFocus in my code... Microsoft Access can't move the focus to the control Grade ...
1
by: Wayneyh | last post by:
Hello all I am trying to create a search form. I have a table called tblContact which has the field for postcodes in it. I have another table called tblSales which i have created a query to link...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...
0
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,...

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.