Inherited Form

E

EmilH

Hi.

I couldn't find it in msdn. I have a form AddCategory. Now I need
EditCategory form which should look exactlay like AddCategory. I add an
inherited form to the project. Now all controls' properties are read-only. I
need to change AddButton's Name and Text properties to Edit. I change
Modifier property of the parent control to public, but it doesn't solve.

Can anybody help me?
Thanks.
Emil.
 
E

EmilH

I changed modifier of InitializeComponents method of parent form, it worked,
but the name property still remains read-only. Is there any way to 'unlock'
all properties of the inherited form?
 
B

Bruce Wood

Hi.

I couldn't find it in msdn. I have a form AddCategory. Now I need
EditCategory form which should look exactlay like AddCategory. I add an
inherited form to the project. Now all controls' properties are read-only. I
need to change AddButton's Name and Text properties to Edit. I change
Modifier property of the parent control to public, but it doesn't solve.

Whilst editing the AddCategory form in the Windows Forms Designer, you
need to change the AddButton's protection from "private" to
"protected". Then you will be able to modify its properties from the
Designer.

By the way, I don't think that you want to modify the button's Name
property... that's what it's called in the code. The Text is what
shows on the button.
 
E

EmilH

Thanks for reply, Bruce.
I'll try to explain more exactly what I need.

AddCategory EditCategory

They both contain button addBut. 2nd is inherited from the first. I want to
be able to change addBut.Name and addBut.text properties of the second form
(EditCategory) in the designer. Butchanging modifier to protected didn't
solve the problem. I changed it to public (the most accessible modifier)
before. I'm not even able to delete any control on the inherited form.

Is there anything to do with a 'new' keyword?

Emil.
 
P

Peter Duniho

[...]
They both contain button addBut. 2nd is inherited from the first. I want
to
be able to change addBut.Name and addBut.text properties of the second
form
(EditCategory) in the designer. Butchanging modifier to protected didn't
solve the problem. I changed it to public (the most accessible modifier)
before. I'm not even able to delete any control on the inherited form.

Did you change the access modifier for the button field itself? Or did
you change the access modifier for the InitializeComponent() method? Your
previous post indicates you did the latter, but it's the former that you
need to do. Changing the modifier from "private" to "protected" should be
sufficient.

As for deleting controls, I don't see any reason that you should expect to
be able to do that. The control is in the base form, not the derived
form. If you could delete the control from the derived form, that would
require removing it from the base form as well, which of course would
screw up that form as well as any other form that inherits it.

Likewise changing the "Name" property of the button. Since the "Name" is
actually used for the name of the field in the base form, you cannot
change it in the derived form, and for the same reasons that you can't
delete the control altogether.

If you don't want a base form control to show, you'll have to add run-time
code to either hide or remove it from the form instance. You do not have
any option for changing the name in the designer, other than changing it
in the base form. However, as with deleting the control, you should be
able to have the Name property of the control in your run-time code (but
at that point, it won't change the in-code name of the field for the
control...just the "Name" property itself).

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top