Click here to Skip to main content
15,899,679 members
Home / Discussions / C#
   

C#

 
GeneralArrayList Help Needed for Newbie... Pin
gman4429-Jul-04 11:32
gman4429-Jul-04 11:32 
GeneralRe: ArrayList Help Needed for Newbie... Pin
Christian Graus29-Jul-04 11:52
protectorChristian Graus29-Jul-04 11:52 
GeneralRe: ArrayList Help Needed for Newbie... Pin
leppie29-Jul-04 21:41
leppie29-Jul-04 21:41 
GeneralWildcard filename pattern matching for c# Pin
RobC.29-Jul-04 11:29
RobC.29-Jul-04 11:29 
GeneralRe: Wildcard filename pattern matching for c# Pin
Nick Parker29-Jul-04 12:37
protectorNick Parker29-Jul-04 12:37 
GeneralSetting default button in a user control Pin
Member 117376029-Jul-04 11:18
Member 117376029-Jul-04 11:18 
GeneralRe: Setting default button in a user control Pin
Member 117376030-Jul-04 2:20
Member 117376030-Jul-04 2:20 
GeneralRe: Setting default button in a user control Pin
Heath Stewart30-Jul-04 4:33
protectorHeath Stewart30-Jul-04 4:33 
There's a couple different things you could do. One would be to define those properties on your UserControl derivative, and then when you add that to a Form (it's going to happen eventually) assign Form.AcceptButton to MyUserControl.AcceptButton. You could even use a designer to do this automatically.

Another one - though I'm not sure it'll work - is to extend the Button class and override the CreateParams property like so:
// Define an alias for easy use since the class and property name cause problems
using CP = System.Windows.Forms.CreateParams;
// ...
const int BS_DEFPUSHBUTTON = 0x01;
protected override CP CreateParams
{
  get
  {
    CP cp = base.CreateParams;
    cp.Style |= BS_DEFPUSHBUTTON;
    return cp;
  }
}
If you wanted, you could encapsulate this behavior into a property that conditionally sets the BS_DEFPUSHBUTTON window style.

The questionable part is whether the Windows Management APIs will really care if this button is not in a Form (a dialog, as it knows it). Good luck!

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Setting default button in a user control Pin
Member 117376030-Jul-04 4:50
Member 117376030-Jul-04 4:50 
Generalmp3 player Pin
Member 80940929-Jul-04 11:04
Member 80940929-Jul-04 11:04 
GeneralRe: mp3 player Pin
Nick Parker29-Jul-04 11:36
protectorNick Parker29-Jul-04 11:36 
GeneralRe: mp3 player Pin
crushinghellhammer29-Jul-04 12:17
crushinghellhammer29-Jul-04 12:17 
QuestionDrawing twice causes exception? Pin
Pain_Elemental29-Jul-04 9:34
Pain_Elemental29-Jul-04 9:34 
AnswerRe: Drawing twice causes exception? Pin
Heath Stewart29-Jul-04 9:42
protectorHeath Stewart29-Jul-04 9:42 
GeneralRe: Drawing twice causes exception? Pin
Pain_Elemental29-Jul-04 20:26
Pain_Elemental29-Jul-04 20:26 
GeneralRe: Drawing twice causes exception? Pin
Heath Stewart30-Jul-04 3:13
protectorHeath Stewart30-Jul-04 3:13 
GeneralRe: Drawing twice causes exception? Pin
Pain_Elemental30-Jul-04 3:34
Pain_Elemental30-Jul-04 3:34 
GeneralRe: Drawing twice causes exception? Pin
Pain_Elemental30-Jul-04 10:37
Pain_Elemental30-Jul-04 10:37 
GeneralDifferent behavior on different machines Pin
DougW4829-Jul-04 9:22
DougW4829-Jul-04 9:22 
GeneralRe: Different behavior on different machines Pin
Heath Stewart29-Jul-04 9:36
protectorHeath Stewart29-Jul-04 9:36 
GeneralRe: Different behavior on different machines Pin
DougW4829-Jul-04 9:59
DougW4829-Jul-04 9:59 
GeneralCryptography Pin
Wender Oliveira29-Jul-04 9:14
Wender Oliveira29-Jul-04 9:14 
GeneralRe: Cryptography Pin
Heath Stewart29-Jul-04 9:22
protectorHeath Stewart29-Jul-04 9:22 
Questioncontrol InvokeRequired() always necessary? Pin
vista2729-Jul-04 8:32
vista2729-Jul-04 8:32 
AnswerRe: control InvokeRequired() always necessary? Pin
Judah Gabriel Himango29-Jul-04 8:58
sponsorJudah Gabriel Himango29-Jul-04 8:58 

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.