ToniMontana Posted August 27, 2004 Posted August 27, 2004 Hi, I have the following problem: In my mainForm I have several different user-controls, which I can control with "show", "hide" etc... I want to set the Acceptbutton of each user-control programatically just before it will be displayed with "show". For this reason I also need to disable the Acceptbutton of a user-control. But I saw that this isnt possible! If I display only one user-control in my form and click on it so that it gets the focus, then the first button of it will be the Acceptbutton automatically! How can I switch off this feature? If I say user-control.AcceptButton = null nothing changes... Quote Greetings, Toni.
Mothra Posted August 28, 2004 Posted August 28, 2004 If I say user-control.AcceptButton = null nothing changes... The keyword 'null' is not supported in Visual Basic (if this is a VB app). You have to use 'nothing' instead. Quote Being smarter than you look is always better than looking smarter than you are.
Joe Mamma Posted August 28, 2004 Posted August 28, 2004 perhaps wiring a method to your user-control's VisibleChanged event. Perhaps in the constructor. Design-time or runtime wiring may be called for instead. But I believe that is what you want to happen. This way, when the visiblity of the user control changes, you can programatically adjust your control. . . Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
ToniMontana Posted August 30, 2004 Author Posted August 30, 2004 Thanks for the replies. But it's not the problem to do "some action" at the visible-changed-event of my user-control. I must know HOW TO SWITCH OFF THE ACCEPT-BUTTON AND CANCEL-BUTTON. Any ideas? Quote Greetings, Toni.
Administrators PlausiblyDamp Posted August 30, 2004 Administrators Posted August 30, 2004 Is the control's AcceptButton property actually being set to true or is it simply that the first control within your user control is a button and that it is gaining the focus? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Arch4ngel Posted August 30, 2004 Posted August 30, 2004 What I remembered... is that AcceptButton is the button with the focus... don't know if it can be the first in the form... but I know that you can't "disable" that. Unless you make a custom control. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
ToniMontana Posted August 30, 2004 Author Posted August 30, 2004 Hi PlausiblyDamp, hi Arch4ngel, the fact is: the property AcceptButton is a property of a form, not of a control. You have to say to the form, which the accept-button and cancel-buttons are. If you have a user-control like I have, and you switch off some buttons via buttonxyz.Enabled = false and the form gets the focus again, the system will assign the "accept" to the first enabled button of the user-control. You can see that, because the button then has an additional coloured frame. But I want to decide programmatically, which button is the accept-button. I dont know how to do that if the systems sets it by itself. To delete every "accept-button-functionality" of my user-control would help in this situation, then I would be able to set it later programmatically to a button, which is enabled then. @Arch4ngel: What do you mean by a "custom-control"? I already have a user-control, which is a class, derived from System.Windows.Forms.UserControl. Quote Greetings, Toni.
Joe Mamma Posted August 30, 2004 Posted August 30, 2004 did ypu see my reply? Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Arch4ngel Posted August 30, 2004 Posted August 30, 2004 Go see the previous post of Joe Mamma (that's the first thing - Joe Mamma... no need to thanks me) After that... you can set your Default AcceptButton in the OnEnter event of your form. This could be possible. Ask more question if you want. It's a cool little funny functionnality Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
ToniMontana Posted August 31, 2004 Author Posted August 31, 2004 Thanks Joe Mamma. I will see... Quote Greetings, Toni.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.