473,671 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forcing the dotted rectangle on a button?

Hi,
Before I go into detail, is there any way to force a button to get that
dotted box on it that shows it's in focus? Just saying btn1.Focus(); isn't
working for me. Btn1 is definitely the thing being focused on, but you
wouldn't know by just looking at it. And it seems that the only way to get a
button to show highlight is to Tab into it.

So, the weird details...
Say I put a custom button on my form (and gave it tabstop 1). I then add a
textbox with tabstop 2. And finally another button (tabstop 3). If I click in
the textbox and press the Tab key, the 2nd button gets that dotted line, no
problem. Same goes if I press Shift-Tab (the 1st button shows focus). I made
the textbox so that it recognizes if the up or down keys are hit, so when I'm
in the textbox and press the up key, I say:
if (e.KeyCode == Keys.Up){SendKe ys.Send("+{Tab} ");}
and have no problem here either - the first button shows focus.
But if down is pressed:
if (e.KeyCode == Keys.Down){Send Keys.Send("{Tab }");}
it freaks out and everything freezes so that I have to open task manager to
close it down.

One other thing - if a button has been highlighted (tabbed into) once,
saying just btn1.Focus(); is enough. But, of course, I can't be sure that tab
will always be pressed.
Hope this makes sense.
Thanks for any help on this!
Mel
Jan 18 '06 #1
2 2781
When you say "custom button" are you certain that this control follows the
design rules for UI feedback?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"melanieab" <me*******@disc ussions.microso ft.com> wrote in message
news:A0******** *************** ***********@mic rosoft.com...
Hi,
Before I go into detail, is there any way to force a button to get that
dotted box on it that shows it's in focus? Just saying btn1.Focus(); isn't
working for me. Btn1 is definitely the thing being focused on, but you
wouldn't know by just looking at it. And it seems that the only way to get
a
button to show highlight is to Tab into it.

So, the weird details...
Say I put a custom button on my form (and gave it tabstop 1). I then add a
textbox with tabstop 2. And finally another button (tabstop 3). If I click
in
the textbox and press the Tab key, the 2nd button gets that dotted line,
no
problem. Same goes if I press Shift-Tab (the 1st button shows focus). I
made
the textbox so that it recognizes if the up or down keys are hit, so when
I'm
in the textbox and press the up key, I say:
if (e.KeyCode == Keys.Up){SendKe ys.Send("+{Tab} ");}
and have no problem here either - the first button shows focus.
But if down is pressed:
if (e.KeyCode == Keys.Down){Send Keys.Send("{Tab }");}
it freaks out and everything freezes so that I have to open task manager
to
close it down.

One other thing - if a button has been highlighted (tabbed into) once,
saying just btn1.Focus(); is enough. But, of course, I can't be sure that
tab
will always be pressed.
Hope this makes sense.
Thanks for any help on this!
Mel

Jan 19 '06 #2
Hi!
I followed the example to create a toggle button in the Microsoft Visual C#
..Net Step By Step version 2003 book - Chapter 23 "Creating GUI Components"
(page 427), so I'm guessing I followed the rules (I'm still kind of new and
don't know all the rules yet). After I asked the question, I did realize
that my button is really descended from a CheckBox, but I don't think that
would make any difference (?), and I still don't think it would explain the
strange behavior of accepting sending a +Tab but not a Tab (I'm trying to
work around another strange behavior at the moment that's a result of these
'buttons'). Anyway, thanks very much for trying to help me with this!
Cheers,
Mel

"Bob Powell [MVP]" wrote:
When you say "custom button" are you certain that this control follows the
design rules for UI feedback?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


Jan 19 '06 #3

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

Similar topics

4
8503
by: Doors of Perception | last post by:
As you probably know, when you click on a link in MSIE and go to a page, then when you click the "back" button, you see a dotted box outlining the link on which I just clicked. As far as I'm aware, no versions of Opera support this desired capability natively, so I've experimented, as best I could, with using a custom CSS file which contains the following: a:hover { outline: 2px dotted black; }
1
3759
by: Jeff Waskiewicz | last post by:
Hello All, I'm trying to solve a nagging problem. The goal is to draw a rectangle over the top of all the other controls on a form. Specifically, over a ChartFX control. The user would draw the rectangle using the right mouse button to represent the area of the chart they want to zoom on. I haev been able to draw the rectangle on a blank form but I cannot get it to draw on top of other controls. I have pasted in the code i am using ....
2
3140
by: charlieopenshaw | last post by:
I have a form listview and have used the MouseDown event to launch a modal dialog if a particular cell is clicked. This works fine but upon closing the dialog I am left with a dotted rectangle drawn between where the original click was and where I clicked to close the dialog. Until another mouse click occurs this rectangle resizes as you move the mouse. I guess this is because the MouseUp event hasn't fired yet (or fired on the modal...
2
4316
by: FredZimmerman | last post by:
When I have my black backround for Body and my button is a round .GIF image (actually image has round green button on black backround, whole thing a rectangle), when I click on the button (hyperlink) a white dotted line surrounds the rectangular gif with round button image in the middle. How do I get rid of dotted white line on select of the hyperlink? Fred Z.
0
8476
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
8393
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
8914
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...
1
8598
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
8670
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...
1
6223
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
4224
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...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
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

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.