Click here to Skip to main content
15,900,258 members
Home / Discussions / C#
   

C#

 
AnswerRe: Select Section of Image Pin
Robert Rohde30-Apr-06 22:04
Robert Rohde30-Apr-06 22:04 
GeneralRe: Select Section of Image Pin
smarttom991-May-06 4:31
smarttom991-May-06 4:31 
QuestionList Box Pin
Sean8930-Apr-06 14:58
Sean8930-Apr-06 14:58 
AnswerRe: List Box Pin
Kuira30-Apr-06 16:56
Kuira30-Apr-06 16:56 
GeneralRe: List Box Pin
Sean891-May-06 9:10
Sean891-May-06 9:10 
GeneralRe: List Box Pin
Kuira1-May-06 13:33
Kuira1-May-06 13:33 
QuestionPersistent Button Pin
IceWater4230-Apr-06 13:35
IceWater4230-Apr-06 13:35 
AnswerRe: Persistent Button Pin
Stanciu Vlad30-Apr-06 21:54
Stanciu Vlad30-Apr-06 21:54 
The main problem you encounter is that while focused the control processes key messages and hadles them (ie - you press space or enter the button is pressed).

In order to bypass this you have to inherit the Button class and override it's ProcessCmdKey method. This will allow you to skip some keys you don't want to be processed.

Here's an example :

namespace MyCustomControls
{
    public class SpecialButton : Button
    {
        ArrayList skipTheseKeys;

        public SpecialButton() 
        {
             skipTheseKeys = new ArrayList();

             skipTheseKeys.Add(Keys.Space);   // ignore space for pressing 
             skipTheseKeys.Add(Keys.Tab);     // ignore tab forlosing focus
        }

        // override the ProcessCmdKey and handle specific key's yourself
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (skipTheseKeys.Contains(keyData))
                return true;  // we have succsesfully processed this key
            else
                return base.ProcessCmdKey(ref msg, keyData);   // let the buttonclass handle this key
        }
    }
}


protected internal static readonly ... and I wish the list could continue ...

GeneralRe: Persistent Button Pin
IceWater421-May-06 5:02
IceWater421-May-06 5:02 
GeneralRe: Persistent Button Pin
Stanciu Vlad1-May-06 7:13
Stanciu Vlad1-May-06 7:13 
GeneralRe: Persistent Button Pin
IceWater421-May-06 8:08
IceWater421-May-06 8:08 
GeneralRe: Persistent Button Pin
Stanciu Vlad1-May-06 8:25
Stanciu Vlad1-May-06 8:25 
GeneralRe: Persistent Button Pin
IceWater421-May-06 18:17
IceWater421-May-06 18:17 
Questionopen a word document Pin
deepak130-Apr-06 11:26
deepak130-Apr-06 11:26 
GeneralRe: open a word document Pin
Guffa30-Apr-06 11:57
Guffa30-Apr-06 11:57 
Questionhyperlink in MessageBox? Pin
manusse30-Apr-06 10:03
manusse30-Apr-06 10:03 
AnswerRe: hyperlink in MessageBox? Pin
Graham Nimbley30-Apr-06 10:40
Graham Nimbley30-Apr-06 10:40 
AnswerRe: hyperlink in MessageBox? Pin
Christian Graus30-Apr-06 11:17
protectorChristian Graus30-Apr-06 11:17 
QuestionI want to installed product.. but.... Pin
Real Coder30-Apr-06 8:00
Real Coder30-Apr-06 8:00 
GeneralRe: I want to installed product.. but.... Pin
Guffa30-Apr-06 9:37
Guffa30-Apr-06 9:37 
AnswerRe: I want to installed product.. but.... Pin
Robin Panther30-Apr-06 10:23
Robin Panther30-Apr-06 10:23 
GeneralRe: I want to installed product.. but.... Pin
Real Coder1-May-06 7:03
Real Coder1-May-06 7:03 
QuestionHow to count number of word in text Pin
eyalso30-Apr-06 7:57
eyalso30-Apr-06 7:57 
AnswerRe: How to count number of word in text Pin
Robin Panther30-Apr-06 10:27
Robin Panther30-Apr-06 10:27 
GeneralRe: How to count number of word in text Pin
eyalso30-Apr-06 10:46
eyalso30-Apr-06 10:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.