How to Create Custom Windows Form in C#

What the heck Is going on Guys! This Is Ghanshyam Dayma and first of all I want to say sorry! To all my subscribers Because I’m Posting this Video afte a long Time. Actually! I was kind of busy With my academic thing so therefore I was not able to Upload a new Video but Now I’m Totally free I I’ve successfully Completed in my MCA. so therefore I have too much Time to Upload new Video. Now Let’s Talk About This Video, in This Video tutorial I will show you how to create a custom Windows Form using C-Sharp dotnet. So Without Wasting Time, Let’s Create our Custom Form, so open your Visual Studio Go to file menu>New and then Project so as you know We are Going to create a windows form Application so select C# Template and then Windows form Application and then Name your Project m gonna Name this Let’s Say Custom Form 1 alright! click ok. so this is your default ugly form with ugly Border. It looks Like This when you run it Oops Alright! so this your Default Form Which is Look like very ugly so let me Remove This Border so select your Form and Go to the Property Window and Look for the Property FormBorderStyle and Change this value to none Right The Border has Been Removed now We will Create our Own Border Using the Panel Controls so go to the toolbox and drag One Panel. Alright! so Let Me First Change the Background color of the Form so for that select your Form and go to the Property Window again and Change The Back Color. So let me Choose the Darker one Window Frame Or Let me Choose the more darker one. Alright so now Let me Change the color of the Panel so? Hot Track Alright so this Is our Top Border and let me Copy and paste it Alright so this Is our Bottom Border Now select the Top Panel and Again go to the Property Window and Scroll Down and Let me Change This to 3 and the Dock Property to Top All right Let me do the Same for the Bottom Border The Dock Property is Bottom and The Size is 3 Alright so you can, also Resize This top border like this so it is Look like the title Bar So you Can, also place One Button here for closing the Form like This All right Let me do this and Let Me change the Text to X and The FlatStyle to flat and The ForeColor is white All right Nice Let me drag One Label Here and Change The Property, Font for that To Monotype Sixteen Or twenty and The ForeColor is white Let me change this again. Alright !so Custom Windows Form All right you Can, also place an Icon here using the Picture Box Alright! And One More Thing select the Form and again go to property and Scroll down Here To Start Position and Change This to Center Screen so this will Open The form to the Center Screen Now Let’s run This Alright so here is your! Here is your Custom Windows Form. it Looks very Cool Actually So but There is one Problem it Is not draggable Right Now like the default one so And it Is not Closing, also we have not defined the Code so To Make This Form Draggable, We have to write Two events Here! The First Event is MouseDown Event and The second Event Is MouseMove event so to Make This Form Draggable Select The form First and then go to the Property Window and You will find This Symbol Here This is the event Symbol so click this and Now Scroll Down to the Mouse event Here and Double You will find this Mouse Down Event and Mousemove Event so first double click to this Mouse Down Event Like This and Here First Thing, We will define One Variable here. so Just type Public Point MouseLocation All right so this Is one Variable and Now come Back to the mousedown Event Here and This type Mouse Location Is equal to new Point in Parentheses – E dot Dot X Comma – Oops – E dot Y axis Oops All right Semicolon and Now again go to the design Window and Again go to the Event and This Time Double Click to the Mousemove Event AlRight so Here just Type one if Condition so if e Dot Button Is Equal To equal to Double Equal to Mouse Location Not Mouse Location, MouseButtons dot Left Alright if This is true then then Point Point MousePos this is another Variable Control Dot Mouse Position oops not Botton MousePosition it is Mouse Position And now MousePos Is equal to, oh, sorry not equal to MousePos dot offset in Parenthesis Mouse Location Mouse Location dot X-Axis Comma Mouse Location Dot Y-Axis and Then Semicolon and Now type Location Location Is Equal to Mouse Pause all right so The coding is Done and Now do this also me dot oops not me dot this dot close so This will Close the form Alright! Now Let’s run this and now you can See the Form is draggable right now so Is it cool na? You Can, also add the Border to the left Side and also to the right side using the Panel Hope you guys Like this Video Please if You are new Here then, Please subscribe this Channel and don’t Forget to Share This Video With your friends I will see you in next Video. 🙂


Add a Comment

Your email address will not be published. Required fields are marked *