1 00:00:01,070 --> 00:00:06,950 In our previous video we started making some modifications to the floor for application most notably 2 00:00:06,950 --> 00:00:17,210 the fact that we created a new window or a new wind farm and then we set it to be the initial form to 3 00:00:17,210 --> 00:00:17,750 be launched. 4 00:00:17,750 --> 00:00:19,610 When our application starts. 5 00:00:19,640 --> 00:00:26,810 So when I click start and we would would traditionally see the car into form nowhere seeing our main 6 00:00:26,810 --> 00:00:27,610 window. 7 00:00:27,650 --> 00:00:33,020 So now we need to start transforming main window into an actual I mean window and container. 8 00:00:33,050 --> 00:00:39,020 We started looking at the concept of multi document interfaces and so that's what we're going to do 9 00:00:39,080 --> 00:00:40,540 in this video. 10 00:00:40,550 --> 00:00:46,170 Now I'm relaunching mean windows design and I'm want to remove this label and I'm going to just meet 11 00:00:46,190 --> 00:00:52,310 this mean window a bit bigger so I can always just you know Adjust the width or the natural width of 12 00:00:52,310 --> 00:00:54,010 the window with height. 13 00:00:54,020 --> 00:01:01,870 Of course by dragging it out by expanding it or collapsing it accordingly. 14 00:01:02,000 --> 00:01:06,310 No what I want from the main window is to be able to launch all the windows right. 15 00:01:06,320 --> 00:01:11,750 No I worry too and they have one other but you know we're building it's an entire application I'm sure 16 00:01:11,810 --> 00:01:17,420 whether you sketched it or you conceptualized it you can imagine that there are a few windows that we 17 00:01:17,420 --> 00:01:22,370 will probably need to build before we can have an application that will probably go and sell to a car 18 00:01:22,370 --> 00:01:23,440 rental agency. 19 00:01:23,460 --> 00:01:25,630 No let's get into the meat of the matter. 20 00:01:25,630 --> 00:01:31,180 So what I want to do is go to my tool box and I will want a menu. 21 00:01:31,220 --> 00:01:39,440 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 22 00:01:39,440 --> 00:01:44,750 strip will allow me to start building a menu so as with most Windows applications you know you have 23 00:01:44,760 --> 00:01:48,990 file you have edit to view et cetera et cetera. 24 00:01:49,030 --> 00:01:53,980 I am actually using the same technology that use you this kind of menu. 25 00:01:54,080 --> 00:01:56,180 That is the menu strip right. 26 00:01:56,180 --> 00:02:02,780 So I'm just I just being dragged over this menu strip and then know it's allowing me to start typing 27 00:02:03,050 --> 00:02:04,760 the menu options I have. 28 00:02:04,760 --> 00:02:08,650 So I can see and manage vehicle listing. 29 00:02:08,830 --> 00:02:09,420 All right. 30 00:02:09,440 --> 00:02:15,440 So that's like I mean you know that would be in my file and then it can be multilevel so for the next 31 00:02:15,440 --> 00:02:25,480 level I'm going to have ADD vehicle I'm going to of remove vehicle maybe 32 00:02:28,030 --> 00:02:35,600 edit vehicle and the view listing all right. 33 00:02:35,600 --> 00:02:40,670 So those are the many options that I envision for the managing of vehicles. 34 00:02:40,670 --> 00:02:46,310 I mean as we go along we probably will take those all the time because maybe we can get at least three 35 00:02:46,310 --> 00:02:48,880 of these done from one form. 36 00:02:48,890 --> 00:02:51,710 But for now I'm just showing you that that's all you can global. 37 00:02:51,720 --> 00:02:52,910 Building a menu. 38 00:02:52,970 --> 00:02:54,010 All right so that's money. 39 00:02:54,020 --> 00:02:59,930 Vehicle listing and then I'm going to say manage your entire credit cards right. 40 00:03:00,260 --> 00:03:08,700 And then the next level would be to add a rental or a card we can view archive. 41 00:03:08,840 --> 00:03:15,620 So this would be the archive of all the windows that have occurred in the database so far and then we'll 42 00:03:15,620 --> 00:03:19,120 probably want to edit or record. 43 00:03:19,700 --> 00:03:20,660 So the rationale. 44 00:03:20,660 --> 00:03:25,850 I'm not going to put delete because maybe you would want your user to be able to order into a record 45 00:03:25,880 --> 00:03:27,500 which we have a screen for already. 46 00:03:27,500 --> 00:03:29,300 That's all we started. 47 00:03:29,300 --> 00:03:34,650 We would want them to view all our entire records that have happened and maybe you'd want them to edit 48 00:03:34,650 --> 00:03:40,490 our entire record because you know if somebody changed their mind a boulder into the agreements they 49 00:03:40,490 --> 00:03:44,180 were supposed to bring about DOS then they want to bring it backwards instead and they should be able 50 00:03:44,180 --> 00:03:46,030 to go in and edits that rental record. 51 00:03:46,040 --> 00:03:47,270 You know stuff like that. 52 00:03:47,450 --> 00:03:50,920 So I'm going to leave it at this for no. 53 00:03:50,930 --> 00:03:54,910 And let's just click start and see what that looks like. 54 00:03:55,300 --> 00:03:55,740 All right. 55 00:03:55,760 --> 00:04:01,720 So now we have our main window and we see that we have our menu and when we click these buttons well 56 00:04:01,730 --> 00:04:03,230 nothing is happening right. 57 00:04:03,260 --> 00:04:10,430 So we still have some work to do in order to get these menu options actually useful. 58 00:04:10,460 --> 00:04:15,860 So the first one that I think we should work on is the outer entire record since that's the real feature 59 00:04:15,860 --> 00:04:18,250 that we've been building up until now anyway. 60 00:04:18,680 --> 00:04:27,800 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 61 00:04:27,860 --> 00:04:32,090 like I do but when you click it it's supposed to expand if it doesn't then. 62 00:04:32,300 --> 00:04:38,310 Well I think it's until it's editable there I double clicked just no breaking my own cardinal rule. 63 00:04:38,420 --> 00:04:42,280 But when I click it and it becomes edited by press enter and then it drops down. 64 00:04:42,290 --> 00:04:45,670 So if you're having difficulty getting it to drop don't like I just did. 65 00:04:45,800 --> 00:04:47,620 Then that's what I used to go our own dates. 66 00:04:47,620 --> 00:04:51,500 I don't know why my visual studio is behaving this way but I'm just working with it. 67 00:04:51,950 --> 00:04:53,480 Otherwise you shouldn't have a problem. 68 00:04:53,480 --> 00:05:01,360 So what we want is a click event on this menu item because the the deduction would be that when I in 69 00:05:01,390 --> 00:05:07,430 to manage rental records and I click utterance I record and the expectation is that my rental record 70 00:05:07,430 --> 00:05:08,930 window should launch. 71 00:05:09,350 --> 00:05:16,610 So once again click event I can always right click go to properties go to the landing boat and chances 72 00:05:16,640 --> 00:05:21,500 are I can just double click it and it will generate that click event stub for me. 73 00:05:21,560 --> 00:05:29,030 I notice the naming convention is going to tell me the the text that is in the button and then it's 74 00:05:29,030 --> 00:05:33,220 a tool strip menu item underscore the click. 75 00:05:33,290 --> 00:05:35,330 All right so that's a naming convention. 76 00:05:35,450 --> 00:05:43,360 And because I inadvertently the WikiLeaks the main one I got to manage print records click event showing 77 00:05:43,360 --> 00:05:43,540 up. 78 00:05:44,120 --> 00:05:48,950 Now remember that if you get wrong click event and you just delete it you went off to do some amount 79 00:05:48,950 --> 00:05:55,310 of cleanup because if you delete it one time and then you go back to your design you're going to end 80 00:05:55,310 --> 00:06:00,800 up with this nasty looking arrow which is really worse than it really is because you can just go to 81 00:06:00,800 --> 00:06:07,670 code over and a section here and it will show you the line in the generated code that is trying to call 82 00:06:07,670 --> 00:06:15,110 the function that you just deleted so you can just remove that line and then you should have no problems 83 00:06:15,110 --> 00:06:15,780 thereafter. 84 00:06:15,830 --> 00:06:17,540 Of course as you go along you just do. 85 00:06:17,550 --> 00:06:23,120 Control shift then be to continue to build your application to make sure that you have no errors. 86 00:06:23,120 --> 00:06:30,080 So you see my build was successful and I can close any unwanted tabs and my design view has returned 87 00:06:30,170 --> 00:06:31,380 to normal. 88 00:06:31,400 --> 00:06:32,690 So where were we. 89 00:06:32,690 --> 00:06:41,090 We were looking at setting up the Click event for all or many strip our to strip menu item. 90 00:06:41,570 --> 00:06:48,380 So if you remember how we launched main window from our car into form then you can write the code. 91 00:06:48,380 --> 00:06:51,290 Otherwise I'm just going to go and review it one more time. 92 00:06:51,290 --> 00:06:57,300 So what we did in our our entire record was to put in this button purely experiment. 93 00:06:57,560 --> 00:07:03,140 But what it did was it launched the main window so I'm actually going to remove the button because I 94 00:07:03,140 --> 00:07:03,840 don't need it. 95 00:07:03,860 --> 00:07:07,530 It's not useful or it's not necessary going forward. 96 00:07:07,550 --> 00:07:12,200 So I removed it from the design but I'm way into the code behind and I'm just going to review the code 97 00:07:12,200 --> 00:07:14,560 that we wrote in the button click event. 98 00:07:14,620 --> 00:07:20,690 So you'll notice also that removing the controller does not remove the event that was attached to it. 99 00:07:20,690 --> 00:07:22,280 So the event is still there. 100 00:07:22,310 --> 00:07:27,020 It just has zero references because there's nothing that is calling it. 101 00:07:27,500 --> 00:07:34,100 So instead of this click event what we did was launch an instance off the window or the form that we 102 00:07:34,100 --> 00:07:40,670 want to launch and then we called the Dot show function inside of that object. 103 00:07:40,670 --> 00:07:43,810 So I'm actually just going to remove this unwanted click event. 104 00:07:43,840 --> 00:07:48,710 So if you had it you can remove it if you feel like you want to keep it that's no problem you leave 105 00:07:48,710 --> 00:07:49,620 it alone. 106 00:07:49,670 --> 00:07:57,800 But I'm going back over to my main window my click event and the window that I intend to launch is ad 107 00:07:57,960 --> 00:07:59,140 rental records. 108 00:07:59,150 --> 00:08:09,180 So I need a variable and I'm going to use var this time someone to say var ad earned a record. 109 00:08:09,190 --> 00:08:09,670 All right. 110 00:08:09,690 --> 00:08:20,370 So just fix some spelling arrows here at her entire record is equal to a new instance of my class ad 111 00:08:20,480 --> 00:08:22,110 her entire record. 112 00:08:22,110 --> 00:08:29,110 So notice of course that yes it's the same name but one is common case a one is it's a. 113 00:08:29,190 --> 00:08:30,330 This one is a class name. 114 00:08:30,330 --> 00:08:36,920 This one is the object name so it does make sure that you adhere to the strict rules when it comes to 115 00:08:36,980 --> 00:08:38,100 kissing. 116 00:08:38,100 --> 00:08:42,820 All right so now that I have been cleared this object the next thing I need to do is say add or into 117 00:08:42,830 --> 00:08:46,450 a record dot show. 118 00:08:46,510 --> 00:08:47,590 All right. 119 00:08:47,600 --> 00:08:51,210 And then I can save and then press start. 120 00:08:51,700 --> 00:08:54,820 And then when our window launches we're going to test it out. 121 00:08:54,820 --> 00:08:59,640 So I click ad her entire record and there it is once again it came up on my other screen. 122 00:08:59,650 --> 00:09:06,670 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 123 00:09:06,670 --> 00:09:09,420 it is going to launch that window right. 124 00:09:09,460 --> 00:09:16,300 So that's not desirable one and two is that this form came up on my screen because it's chemical. 125 00:09:16,330 --> 00:09:21,940 But any point where it feels comfortable and that's not necessarily the experience that we want we would 126 00:09:22,180 --> 00:09:29,530 prefer that this form is kind of tethered to the main window and that when I close the main window everything 127 00:09:29,530 --> 00:09:35,590 closes and everything is tethered to the me window windows so then we have two other things that we 128 00:09:35,590 --> 00:09:36,610 need to do. 129 00:09:36,640 --> 00:09:42,590 So I'm going to go back to my main window design and I'm going to change a very important option. 130 00:09:42,630 --> 00:09:46,810 We're making the MDI container is concerned. 131 00:09:46,810 --> 00:09:53,770 So multi documents in Duffy's means that each farm would be seen as a document pretty much and then 132 00:09:53,830 --> 00:10:02,560 the MDI periods or that multi document interface parent or container would be the storage place for 133 00:10:02,590 --> 00:10:05,050 all of those documents are all of those forms. 134 00:10:05,050 --> 00:10:11,080 So as soon as our farm is created it is created inside of the parent and it cannot exist outside of 135 00:10:11,080 --> 00:10:12,130 the parent. 136 00:10:12,130 --> 00:10:19,720 So what we need to do is in main window we right click goes or properties and then we look for our property 137 00:10:20,050 --> 00:10:22,360 is MDI container. 138 00:10:22,420 --> 00:10:29,230 So you'll find that under Windows style and then you can change it is MDI container you mean that true. 139 00:10:29,260 --> 00:10:34,750 So notice the difference in its appearance when it's false it looks you know lively bright that more 140 00:10:34,750 --> 00:10:36,310 vibrant it looks more alive. 141 00:10:36,640 --> 00:10:42,570 However when I see it true then it looks great oats and kind of did all right. 142 00:10:42,730 --> 00:10:48,040 But then that is one of those necessary evils to get it to be the MDI container. 143 00:10:48,040 --> 00:10:55,780 No we've made it the container but we have one more step where when we're launching our window we need 144 00:10:55,780 --> 00:11:00,250 to tell the window that it's spear and tool spear and who the parent is rather. 145 00:11:00,280 --> 00:11:00,960 Right. 146 00:11:00,970 --> 00:11:06,940 So right now he just launches even though this is the MDI appearance the window that is being launched 147 00:11:06,940 --> 00:11:09,940 doesn't know that this is an MBA child. 148 00:11:09,940 --> 00:11:10,300 All right. 149 00:11:10,540 --> 00:11:19,330 So I'm going to add this other function where I went to see I'd entire record thoughts are what I'm 150 00:11:19,330 --> 00:11:23,220 going to change our property or other something outer into the record. 151 00:11:23,220 --> 00:11:31,800 Dot M. The I parents right is equal to this. 152 00:11:31,960 --> 00:11:32,670 All right. 153 00:11:32,770 --> 00:11:35,440 So let me explain exactly what's happening here. 154 00:11:35,470 --> 00:11:40,480 So one we already know that we're launching all we know we know that we're showing. 155 00:11:40,510 --> 00:11:43,440 So we're declaring the object and then we're showing it. 156 00:11:43,450 --> 00:11:50,800 In between though I'm telling you that having created that object you should know that your MBA appearance 157 00:11:50,860 --> 00:11:53,470 is this and this is a keyword in C sharp. 158 00:11:53,470 --> 00:12:00,370 That means whatever class you're in so mean window is being represented by the keyword. 159 00:12:00,400 --> 00:12:07,900 This because the MBA appearance expects some form or some object of a form to be assigned. 160 00:12:07,930 --> 00:12:12,980 So when I say this this is like a manifestation or an object of the mean window. 161 00:12:13,180 --> 00:12:15,400 It is a keyword in any class. 162 00:12:15,430 --> 00:12:22,280 So if I go to the ad or into records and I see this in inside. 163 00:12:22,280 --> 00:12:24,750 Off the outer entire record class. 164 00:12:24,780 --> 00:12:27,440 This represents over into the record. 165 00:12:27,720 --> 00:12:32,130 So it's always relative to the class it is being used in. 166 00:12:32,160 --> 00:12:35,160 So when I see this inside of the main window. 167 00:12:35,160 --> 00:12:39,570 Notice when I click it it highlights me in the window because C sharp is automatically seeing that. 168 00:12:39,600 --> 00:12:42,730 Okay I know that I represent the mean window. 169 00:12:42,990 --> 00:12:50,160 So I'm seeing that this mean window is the end appearance for the Toronto record at her entire record 170 00:12:50,180 --> 00:12:50,780 object. 171 00:12:51,060 --> 00:12:52,590 And then I want to show it. 172 00:12:52,830 --> 00:12:55,020 So let us see what difference that makes. 173 00:12:55,020 --> 00:13:00,710 So when I click Start our window launches and we can see that dead green we can see the difference. 174 00:13:00,810 --> 00:13:03,450 And then I'm going to launch the outer into the record. 175 00:13:03,480 --> 00:13:08,340 That's what I want to do I notice it launch directly inside of the window this time I didn't have to 176 00:13:08,340 --> 00:13:14,640 go and drag it over the screen and also notice that it is completely contained within this mean window 177 00:13:14,650 --> 00:13:18,800 it cannot go anywhere no matter what it does it cannot go anywhere. 178 00:13:18,810 --> 00:13:21,390 I can minimize it inside of this mean window. 179 00:13:21,390 --> 00:13:27,400 I can maximize it instead of this mean window I can close it on my main window is to alive. 180 00:13:27,420 --> 00:13:35,010 And so this allows me to when I'm finished doing this close and then go ahead and view the archive or 181 00:13:35,100 --> 00:13:40,710 view the listing of vehicles whatever it is I can do that afterwards. 182 00:13:40,710 --> 00:13:41,070 All right. 183 00:13:41,370 --> 00:13:47,990 So that is how the mean window on the MDI rather hold the MDI concept works. 184 00:13:48,040 --> 00:13:54,540 I created me in a window so it could be the MDA container and going forward every other form will be 185 00:13:54,540 --> 00:14:02,730 launched and managed inside of this mean window before I go though I want to make a few cosmetic changes 186 00:14:02,870 --> 00:14:08,820 want to change that takes the main window from just me and window to see something like you know crews 187 00:14:08,850 --> 00:14:17,830 car rentals and then inside of our car and forum when to see order into record instead of seeing car 188 00:14:17,840 --> 00:14:24,050 into a system and also with the change that takes the inside of the title bar for that form. 189 00:14:24,060 --> 00:14:32,730 So then we just exit and let me just do all of them in plain view so right clicking my form go into 190 00:14:32,730 --> 00:14:38,420 properties and then main window and want to call it is crews car rentals. 191 00:14:38,520 --> 00:14:46,830 That's the name of your business are you know car and management system Saad current management system. 192 00:14:46,860 --> 00:14:49,440 Let's make a generic because this is a product that we intend to sell. 193 00:14:49,440 --> 00:14:52,590 So you go on to brand it before we sell it's right. 194 00:14:52,590 --> 00:15:00,930 So that is the name in our mint in our mean window going over to our entire record and when to change 195 00:15:01,110 --> 00:15:04,120 the property for the farm one takes. 196 00:15:04,140 --> 00:15:10,360 So when to right click loads of properties and show me the events I just click over to properties change 197 00:15:10,360 --> 00:15:11,430 the text. 198 00:15:11,460 --> 00:15:21,980 And this one is going to be ad for a card and I'm going to change the text in the label. 199 00:15:22,290 --> 00:15:28,080 Finally and this one is going to see ad and red. 200 00:15:28,320 --> 00:15:28,740 All right. 201 00:15:28,950 --> 00:15:36,660 So there's some cosmetic changes just to make our application look and feel a bit more official and 202 00:15:36,660 --> 00:15:43,020 then you can click start and we can just take one more look at everything just to make sure that everything 203 00:15:43,020 --> 00:15:44,960 is the way that we wanted. 204 00:15:44,970 --> 00:15:50,850 So when I go to add our entire record it's going to launch the new window inside of the application 205 00:15:51,120 --> 00:15:57,030 and it looks a bit better and easier on the eyes know that everything looks like it makes more sense 206 00:15:57,330 --> 00:16:04,140 and we can do a cursor test just to make sure that we didn't break any existing code. 207 00:16:04,200 --> 00:16:12,490 So I'm just going to put in a test or into the record and submit and there we go. 208 00:16:12,570 --> 00:16:18,120 And if you want to go to the database and verify that it went in you can do that but I know it went 209 00:16:18,120 --> 00:16:24,960 in because we didn't modify the form so each form once again is autonomous it's its own documents it's 210 00:16:24,960 --> 00:16:32,160 going to behave off its own intelligence based on what you have core data into the code file for that 211 00:16:32,160 --> 00:16:32,580 form.