Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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...

Greetings,

 

Toni.

Posted

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.

Being smarter than you look is always better than looking smarter than you are.
Posted

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. . .

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.

Posted

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?

Greetings,

 

Toni.

Posted
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.

"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

Posted

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.

Greetings,

 

Toni.

Posted
did ypu see my reply?

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.

Posted

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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...