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

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){SendKeys.Send("+{Tab}");}
and have no problem here either - the first button shows focus.
But if down is pressed:
if (e.KeyCode == Keys.Down){SendKeys.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 2762
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*******@discussions.microsoft.com> wrote in message
news:A0**********************************@microsof t.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){SendKeys.Send("+{Tab}");}
and have no problem here either - the first button shows focus.
But if down is pressed:
if (e.KeyCode == Keys.Down){SendKeys.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
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...
1
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...
2
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...
2
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...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.