RichTextBox text on MDI Parent form Undo Redo etc

J

Jenbo

I have a richtextbox sitting on a tab control on a child form under
the MDI parent. I have undo, redo, cut etc controls on a toolbar on
the same tab control, I can code these no problem as the richtextbox
text property is not blanking so the canundo method is fine to use. I
have these methods also on the MDI parent as well so that the user
should be able to undo, redo, edit the action, text from the main
menu, but when I do the following

MPCE.Child_Forms.Policy policyWin = new MPCE.Child_Forms.Policy();
TabControl tabControlPolicy =
(TabControl)policyWin.Controls["tabControlPolicy"];
TabPage policyPage = (TabPage)tabControlPolicy.Controls["policyPage"];
RichTextBox rtbMain =
(RichTextBox)policyPage.Controls["richTextBoxMain"];

rtbMain.Undo();

the richtextbox text property is being blanked out. I have noticed in
some of the forum's that there was/is a bug in the richtextbox control
that is fixed as of XP SP2 which is what I am running, it had to do
with the text property blanking and methods not being correct because
of this, is this what is happening here, or is it something to do with
the way I am referencing the richtextbox itself, is that not done
correctly?

Any help welcome.

EJ
 
G

Guest

I dont know about the richtextbox issue you describe but the way you are
accessing the richtextbox is bad design. You should at least expose real
properties to enable you to get at it properly. One better is to put an undo
method on the child form so you can just call it. then that does the same as
the child forms button. or have a set of static events for undo etc which the
child form can subscribe to.
 
J

Jenbo

So what's good design, this is the way the designer has put the
controls on the form, the child form contains the tab control and this
contains the richtextbox, should I go and modify the designer file to
have the richtextbox added to the upper level form instead of the tab
control? But it is part of the tab control so is that the right way it
should sit?

What do you mean by real properties, and how would that help, do you
mean that is should be a user control or something like that? But
again the designer will add it to the tab control by default?

Static events for undo - this is like application undo event?

Thanks

EJ


I dont know about the richtextbox issue you describe but the way you are
accessing the richtextbox is bad design. You should at least expose real
properties to enable you to get at it properly. One better is to put an undo
method on the child form so you can just call it. then that does the same as
the child forms button. or have a set of static events for undo etc which the
child form can subscribe to.

--
Ciaran O''Donnellhttp://wannabedeveloper.spaces.live.com



Jenbo said:
I have a richtextbox sitting on a tab control on a child form under
the MDI parent. I have undo, redo, cut etc controls on a toolbar on
the same tab control, I can code these no problem as the richtextbox
text property is not blanking so the canundo method is fine to use. I
have these methods also on the MDI parent as well so that the user
should be able to undo, redo, edit the action, text from the main
menu, but when I do the following
MPCE.Child_Forms.Policy policyWin = new MPCE.Child_Forms.Policy();
TabControl tabControlPolicy =
(TabControl)policyWin.Controls["tabControlPolicy"];
TabPage policyPage = (TabPage)tabControlPolicy.Controls["policyPage"];
RichTextBox rtbMain =
(RichTextBox)policyPage.Controls["richTextBoxMain"];
rtbMain.Undo();

the richtextbox text property is being blanked out. I have noticed in
some of the forum's that there was/is a bug in the richtextbox control
that is fixed as of XP SP2 which is what I am running, it had to do
with the text property blanking and methods not being correct because
of this, is this what is happening here, or is it something to do with
the way I am referencing the richtextbox itself, is that not done
correctly?
Any help welcome.
EJ- Hide quoted text -

- Show quoted text -
 
J

Jenbo

Disregard that message, wasn't thinking, got the modifiers right for
the richtextbox, will try the undo method from the child form.

So what's good design, this is the way the designer has put the
controls on the form, the child form contains the tab control and this
contains the richtextbox, should I go and modify the designer file to
have the richtextbox added to the upper level form instead of the tab
control? But it is part of the tab control so is that the right way it
should sit?

What do you mean by real properties, and how would that help, do you
mean that is should be a user control or something like that? But
again the designer will add it to the tab control by default?

Static events for undo - this is like application undo event?

Thanks

EJ

I dont know about the richtextbox issue you describe but the way you are
accessing the richtextbox is bad design. You should at least expose real
properties to enable you to get at it properly. One better is to put an undo
method on the child form so you can just call it. then that does the same as
the child forms button. or have a set of static events for undo etc which the
child form can subscribe to.
Jenbo said:
I have a richtextbox sitting on a tab control on a child form under
the MDI parent. I have undo, redo, cut etc controls on a toolbar on
the same tab control, I can code these no problem as the richtextbox
text property is not blanking so the canundo method is fine to use. I
have these methods also on the MDI parent as well so that the user
should be able to undo, redo, edit the action, text from the main
menu, but when I do the following
MPCE.Child_Forms.Policy policyWin = new MPCE.Child_Forms.Policy();
TabControl tabControlPolicy =
(TabControl)policyWin.Controls["tabControlPolicy"];
TabPage policyPage = (TabPage)tabControlPolicy.Controls["policyPage"];
RichTextBox rtbMain =
(RichTextBox)policyPage.Controls["richTextBoxMain"];
rtbMain.Undo();
the richtextbox text property is being blanked out. I have noticed in
some of the forum's that there was/is a bug in the richtextbox control
that is fixed as of XP SP2 which is what I am running, it had to do
with the text property blanking and methods not being correct because
of this, is this what is happening here, or is it something to do with
the way I am referencing the richtextbox itself, is that not done
correctly?
Any help welcome.
EJ- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
 

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