Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2005

Tip: Looking for answers? Try searching our database.

disable focus rectangle

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ronnie Smith - 29 Aug 2005 17:11 GMT
Hi - I have a custom control button and I wish to get rid of the focus
rectangle that appears when the user clicks the button. Could you let me know
how to do this please?
Many thanks,
Ronnie
"Peter Huang" [MSFT] - 30 Aug 2005 04:05 GMT
Hi

I think you may just try to override the property below
Control.ShowFocusCues Property
Property Value
true if the control should display focus rectangles; otherwise, false.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwindowsformscontrolclassshowfocuscuestopic.asp

protected override bool ShowFocusCues
{
    get
    {
        return false;
    }
}

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Ronnie Smith - 30 Aug 2005 20:08 GMT
Hi Peter,
Thanks for the suggestion but - no joy - it didn't work.
Any other ideas?
Thanks,
Ronnie

> Hi
>
[quoted text clipped - 20 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 31 Aug 2005 03:18 GMT
Hi

Here is my test code for your reference, you may have a try and let me know
the result.

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace CustomControlButton
{
    /// <summary>
    /// Summary description for UserControl1.
    /// </summary>
    public class CustomButton : System.Windows.Forms.Button
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public CustomButton()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // TODO: Add any initialization after the InitComponent call

        }

        protected override bool ShowFocusCues
        {
            get
            {
                return false;
            }
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if( components != null )
                    components.Dispose();
            }
            base.Dispose( disposing );
        }

        #region Component Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            //
            // UserControl1
            //
            this.Name = "CustomButton";

        }
        #endregion
    }
}

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Ronnie Smith - 31 Aug 2005 20:51 GMT
I tried your code Peter and of course it works EXCEPT for my situation where
I have the FlatStyle property set to Flat. Try it and you'll see the
rectangle appear with a mouse click. Perhaps there is something else we need
to override?

> Hi
>
[quoted text clipped - 73 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 01 Sep 2005 04:50 GMT
Hi

This is a known issue, so far the Flat and standard button has different
draw function so that Flat Button did not check the ShowFocusCues property
when draw button down.
We are planning to fix the problem in the next release.(Whidbey)
So far I think you may have to draw the button yourself to workaround the
problem.
Here is a link as a reference for you.
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/brow
se_thread/thread/92854dc07796453/a00e896d5b41699b?lnk=st&q=ShowFocusCues+Fla
t&rnum=2&hl=zh-CN#a00e896d5b41699b

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Ronnie Smith - 01 Sep 2005 17:14 GMT
Thanks Peter. Sorry I wasn't more specific with my original query. I should
have mentioned that it was a flat button from the start.
Best regards,
Ronnie

> Hi
>
[quoted text clipped - 16 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 02 Sep 2005 04:37 GMT
Hi

You are welcomed!

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.