In our previous video we started making some modifications to the floor for application most notably
the fact that we created a new window or a new wind farm and then we set it to be the initial form to
be launched.
When our application starts.
So when I click start and we would would traditionally see the car into form nowhere seeing our main
window.
So now we need to start transforming main window into an actual I mean window and container.
We started looking at the concept of multi document interfaces and so that's what we're going to do
in this video.
Now I'm relaunching mean windows design and I'm want to remove this label and I'm going to just meet
this mean window a bit bigger so I can always just you know Adjust the width or the natural width of
the window with height.
Of course by dragging it out by expanding it or collapsing it accordingly.
No what I want from the main window is to be able to launch all the windows right.
No I worry too and they have one other but you know we're building it's an entire application I'm sure
whether you sketched it or you conceptualized it you can imagine that there are a few windows that we
will probably need to build before we can have an application that will probably go and sell to a car
rental agency.
No let's get into the meat of the matter.
So what I want to do is go to my tool box and I will want a menu.
So I'm going to bring over menu strip and I'm going to just add it to the top here and then this menu
strip will allow me to start building a menu so as with most Windows applications you know you have
file you have edit to view et cetera et cetera.
I am actually using the same technology that use you this kind of menu.
That is the menu strip right.
So I'm just I just being dragged over this menu strip and then know it's allowing me to start typing
the menu options I have.
So I can see and manage vehicle listing.
All right.
So that's like I mean you know that would be in my file and then it can be multilevel so for the next
level I'm going to have ADD vehicle I'm going to of remove vehicle maybe
edit vehicle and the view listing all right.
So those are the many options that I envision for the managing of vehicles.
I mean as we go along we probably will take those all the time because maybe we can get at least three
of these done from one form.
But for now I'm just showing you that that's all you can global.
Building a menu.
All right so that's money.
Vehicle listing and then I'm going to say manage your entire credit cards right.
And then the next level would be to add a rental or a card we can view archive.
So this would be the archive of all the windows that have occurred in the database so far and then we'll
probably want to edit or record.
So the rationale.
I'm not going to put delete because maybe you would want your user to be able to order into a record
which we have a screen for already.
That's all we started.
We would want them to view all our entire records that have happened and maybe you'd want them to edit
our entire record because you know if somebody changed their mind a boulder into the agreements they
were supposed to bring about DOS then they want to bring it backwards instead and they should be able
to go in and edits that rental record.
You know stuff like that.
So I'm going to leave it at this for no.
And let's just click start and see what that looks like.
All right.
So now we have our main window and we see that we have our menu and when we click these buttons well
nothing is happening right.
So we still have some work to do in order to get these menu options actually useful.
So the first one that I think we should work on is the outer entire record since that's the real feature
that we've been building up until now anyway.
So what I'm going to do is go back to my menu expand it and I don't know some people I have this problem
like I do but when you click it it's supposed to expand if it doesn't then.
Well I think it's until it's editable there I double clicked just no breaking my own cardinal rule.
But when I click it and it becomes edited by press enter and then it drops down.
So if you're having difficulty getting it to drop don't like I just did.
Then that's what I used to go our own dates.
I don't know why my visual studio is behaving this way but I'm just working with it.
Otherwise you shouldn't have a problem.
So what we want is a click event on this menu item because the the deduction would be that when I in
to manage rental records and I click utterance I record and the expectation is that my rental record
window should launch.
So once again click event I can always right click go to properties go to the landing boat and chances
are I can just double click it and it will generate that click event stub for me.
I notice the naming convention is going to tell me the the text that is in the button and then it's
a tool strip menu item underscore the click.
All right so that's a naming convention.
And because I inadvertently the WikiLeaks the main one I got to manage print records click event showing
up.
Now remember that if you get wrong click event and you just delete it you went off to do some amount
of cleanup because if you delete it one time and then you go back to your design you're going to end
up with this nasty looking arrow which is really worse than it really is because you can just go to
code over and a section here and it will show you the line in the generated code that is trying to call
the function that you just deleted so you can just remove that line and then you should have no problems
thereafter.
Of course as you go along you just do.
Control shift then be to continue to build your application to make sure that you have no errors.
So you see my build was successful and I can close any unwanted tabs and my design view has returned
to normal.
So where were we.
We were looking at setting up the Click event for all or many strip our to strip menu item.
So if you remember how we launched main window from our car into form then you can write the code.
Otherwise I'm just going to go and review it one more time.
So what we did in our our entire record was to put in this button purely experiment.
But what it did was it launched the main window so I'm actually going to remove the button because I
don't need it.
It's not useful or it's not necessary going forward.
So I removed it from the design but I'm way into the code behind and I'm just going to review the code
that we wrote in the button click event.
So you'll notice also that removing the controller does not remove the event that was attached to it.
So the event is still there.
It just has zero references because there's nothing that is calling it.
So instead of this click event what we did was launch an instance off the window or the form that we
want to launch and then we called the Dot show function inside of that object.
So I'm actually just going to remove this unwanted click event.
So if you had it you can remove it if you feel like you want to keep it that's no problem you leave
it alone.
But I'm going back over to my main window my click event and the window that I intend to launch is ad
rental records.
So I need a variable and I'm going to use var this time someone to say var ad earned a record.
All right.
So just fix some spelling arrows here at her entire record is equal to a new instance of my class ad
her entire record.
So notice of course that yes it's the same name but one is common case a one is it's a.
This one is a class name.
This one is the object name so it does make sure that you adhere to the strict rules when it comes to
kissing.
All right so now that I have been cleared this object the next thing I need to do is say add or into
a record dot show.
All right.
And then I can save and then press start.
And then when our window launches we're going to test it out.
So I click ad her entire record and there it is once again it came up on my other screen.
So no we have our button working and it's going to work the same way as many times as I'm going to click
it is going to launch that window right.
So that's not desirable one and two is that this form came up on my screen because it's chemical.
But any point where it feels comfortable and that's not necessarily the experience that we want we would
prefer that this form is kind of tethered to the main window and that when I close the main window everything
closes and everything is tethered to the me window windows so then we have two other things that we
need to do.
So I'm going to go back to my main window design and I'm going to change a very important option.
We're making the MDI container is concerned.
So multi documents in Duffy's means that each farm would be seen as a document pretty much and then
the MDI periods or that multi document interface parent or container would be the storage place for
all of those documents are all of those forms.
So as soon as our farm is created it is created inside of the parent and it cannot exist outside of
the parent.
So what we need to do is in main window we right click goes or properties and then we look for our property
is MDI container.
So you'll find that under Windows style and then you can change it is MDI container you mean that true.
So notice the difference in its appearance when it's false it looks you know lively bright that more
vibrant it looks more alive.
However when I see it true then it looks great oats and kind of did all right.
But then that is one of those necessary evils to get it to be the MDI container.
No we've made it the container but we have one more step where when we're launching our window we need
to tell the window that it's spear and tool spear and who the parent is rather.
Right.
So right now he just launches even though this is the MDI appearance the window that is being launched
doesn't know that this is an MBA child.
All right.
So I'm going to add this other function where I went to see I'd entire record thoughts are what I'm
going to change our property or other something outer into the record.
Dot M. The I parents right is equal to this.
All right.
So let me explain exactly what's happening here.
So one we already know that we're launching all we know we know that we're showing.
So we're declaring the object and then we're showing it.
In between though I'm telling you that having created that object you should know that your MBA appearance
is this and this is a keyword in C sharp.
That means whatever class you're in so mean window is being represented by the keyword.
This because the MBA appearance expects some form or some object of a form to be assigned.
So when I say this this is like a manifestation or an object of the mean window.
It is a keyword in any class.
So if I go to the ad or into records and I see this in inside.
Off the outer entire record class.
This represents over into the record.
So it's always relative to the class it is being used in.
So when I see this inside of the main window.
Notice when I click it it highlights me in the window because C sharp is automatically seeing that.
Okay I know that I represent the mean window.
So I'm seeing that this mean window is the end appearance for the Toronto record at her entire record
object.
And then I want to show it.
So let us see what difference that makes.
So when I click Start our window launches and we can see that dead green we can see the difference.
And then I'm going to launch the outer into the record.
That's what I want to do I notice it launch directly inside of the window this time I didn't have to
go and drag it over the screen and also notice that it is completely contained within this mean window
it cannot go anywhere no matter what it does it cannot go anywhere.
I can minimize it inside of this mean window.
I can maximize it instead of this mean window I can close it on my main window is to alive.
And so this allows me to when I'm finished doing this close and then go ahead and view the archive or
view the listing of vehicles whatever it is I can do that afterwards.
All right.
So that is how the mean window on the MDI rather hold the MDI concept works.
I created me in a window so it could be the MDA container and going forward every other form will be
launched and managed inside of this mean window before I go though I want to make a few cosmetic changes
want to change that takes the main window from just me and window to see something like you know crews
car rentals and then inside of our car and forum when to see order into record instead of seeing car
into a system and also with the change that takes the inside of the title bar for that form.
So then we just exit and let me just do all of them in plain view so right clicking my form go into
properties and then main window and want to call it is crews car rentals.
That's the name of your business are you know car and management system Saad current management system.
Let's make a generic because this is a product that we intend to sell.
So you go on to brand it before we sell it's right.
So that is the name in our mint in our mean window going over to our entire record and when to change
the property for the farm one takes.
So when to right click loads of properties and show me the events I just click over to properties change
the text.
And this one is going to be ad for a card and I'm going to change the text in the label.
Finally and this one is going to see ad and red.
All right.
So there's some cosmetic changes just to make our application look and feel a bit more official and
then you can click start and we can just take one more look at everything just to make sure that everything
is the way that we wanted.
So when I go to add our entire record it's going to launch the new window inside of the application
and it looks a bit better and easier on the eyes know that everything looks like it makes more sense
and we can do a cursor test just to make sure that we didn't break any existing code.
So I'm just going to put in a test or into the record and submit and there we go.
And if you want to go to the database and verify that it went in you can do that but I know it went
in because we didn't modify the form so each form once again is autonomous it's its own documents it's
going to behave off its own intelligence based on what you have core data into the code file for that
form.