473,399 Members | 2,159 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,399 software developers and data experts.

Can't make a TextBox to get focus - Compact Framework.

I have a windows form (compact framework) which has three
hidden controls (label, textbox and listbox) at startup.
The controls are enabled, set visible and shown
programatically but I am not able to get the textbox to
get the focus.

Part of the code is below:

Any idea? Thank you.

Carlos Lozano

private void ShowObjects(bool lTogle)
{
// Show or hide controls depending on lTogle

this.Controls.GetEnumerator().Reset();
int Idx = this.Controls.Count-1, fCtrl = 0;
IEnumerator myEnum = this.Controls.GetEnumerator();
while (Idx >= 0 && fCtrl < 24)
{
// Find all the buttons to hide or show them.
// I also tried sendtoback and bringtofront.

myEnum.MoveNext();
Object myObject = myEnum.Current;
if (myObject.GetType().ToString().EndsWith("aButton") )
{
if (fCtrl < 24)
{
aButton Obj = (aButton) myObject;
if (lTogle)
{
Obj.Show();
Obj.BringToFront();
}
else
{
Obj.Hide();
Obj.SendToBack();
}
Obj.Enabled = lTogle;
fCtrl ++;
}
}
Idx --;
}
lName.Enabled = !lTogle; // Label
tName.Enabled = !lTogle; // TextBox
listBox1.Enabled = !lTogle; // ListBox, yes I am sure.
lName.Visible = !lTogle;
tName.Visible = !lTogle;
listBox1.Visible = !lTogle;
if (lTogle)
{
lName.SendToBack();
tName.SendToBack();
listBox1.SendToBack();
lName.Hide();
tName.Hide();
listBox1.Hide();
}
else
{
lName.BringToFront();
tName.BringToFront();
listBox1.BringToFront();
lName.Show();
tName.Show();
listBox1.Show();
}
// After they are show I call tName.focus() from another
routine.
}
}

Nov 15 '05 #1
1 6336
> // After they are show I call tName.focus() from another
routine.


Is your other routine getting called? Why don't you just set the focus here?
Is the focus being set to any other control AFTER you set the focus to
tName?

-JG
Nov 15 '05 #2

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

Similar topics

0
by: Earle Oxner | last post by:
We are developing an application on PocketPC2002 platform and we are trying to make webservice calls using HTTPS. HTTP works fine but HTTPS does not work. The same code which doesn't work on...
2
by: Duncan | last post by:
I am using the evaluation version of CE.NET 4.1. I had also installed the release version of the Compact Framework. I uninstalled the CE.NET 4.1, and then realized I needed it again and...
4
by: Mad Scientist Jr | last post by:
I have a textbox that i am adding to (in codebehind of ASP.NET) and need to ensure that the focus is scrolled to the bottom of the textbox each time the page refreshes, and then set focus to a 2nd...
2
by: Hans Kesting | last post by:
Is it possible to mix code meant for the CompactFramework and code meant for the standard framework? We are trying to make PDA and light-weight "laptop" versions of one application. This means a...
3
by: Keith Smith | last post by:
Is there an easy way to make the {Enter} key take the cursor to the next control without using a KeyDown event on each control?
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
4
by: anoehre | last post by:
Hi! I have a multi-line text box in a compact framework c# application. I need a method to calculate the excact number of lines of the textbox and a method to calculate the number of used lines...
1
by: Vincent | last post by:
I keep receiving the above error message in Microsoft Access when I attempt to click on one of the text boxes on my form. I have done some searching and came across a couple of posts that stated...
4
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have a strange yet very simple problem with the asp.net Textbox web control. On an empty asp.net page, add a single asp:TextBox control with Autopostback=false with nothing else on...
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?
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,...
0
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...
0
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...
0
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...
0
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...
0
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,...

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.