Groups | Blog | Home
all groups > dotnet windows forms > january 2007 >

dotnet windows forms : RichTextBox text on MDI Parent form Undo Redo etc


Jenbo
1/30/2007 7:50:16 AM
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
Ciaran O''Donnell
1/31/2007 5:16:00 AM
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''Donnell
http://wannabedeveloper.spaces.live.com


[quoted text, click to view]
Jenbo
1/31/2007 5:54:54 AM
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


On Jan 31, 1:16 pm, Ciaran O''Donnell
[quoted text, click to view]

Jenbo
1/31/2007 9:12:58 AM
Disregard that message, wasn't thinking, got the modifiers right for
the richtextbox, will try the undo method from the child form.

[quoted text, click to view]

AddThis Social Bookmark Button