تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
Start CeSharp Step by Step
#1
First let me say I don't like write so much in posts then
I wish you keep attention awake
I am beginner like you in CeSharp
while I'm looking for first point after our brother Abu_Ehab adviced me to leave VB to C#
In fact he helps me so much but the youtube Videos doesn't work as well with my weak connection
I tried to find books sites etc.. even I got this site below
Really it for me start point !!!
I can't leave VB right now because I have some work with it for other people
but am sure you hope to be more active more advanced.
then
Let's start

Note: I were feeling hate C# really ! but I wrong


Shy

Your First C# Windows Form



From now on, we're going to be creating Windows Applications, rather than Console Applications. Windows Applications make use of something called a Form. The Form is blank at first. You then add control to your form, things like buttons, text boxes, menus, check boxes, radio buttons, etc. To get your first look at a Windows Form, do the following.

If you still have your Console Application open from the previous section, click File from the menu bar at the top of Visual C# Express. From the File menu, click on Close Solution.

To create your first Windows form project, click the File menu again. This time, select New Projectfrom the menu. When you do, you'll see the New Project dialogue box again. Click Visual C#, under Templates on the left:


Select Windows Forms Application from the available templates (Community 2015 users should see more templates in the middle). Keep the Name on the default ofWindowsFormsApplication1 and then click OK.

When you click OK, a new Windows Application project will be created for you:


The obvious difference from the Console Application you created in the previous section is the blank Form in the main window. Notice the Toolbox, though, on the left hand side. We'll be adding controls from the Toolbox to that blank Form1 you can see in the image above.

If you can't see the Toolbox, you may just see the Tab, as in the following image (the Community 2015 edition has an extra tab called Server Explorer)::


If your screen looks like the one above, move your mouse over to the Toolbox tab. It will expand to look like the first one. If you want to permanently display the Toolbox, click on the pin symbol in the middle:

[صورة مرفقة: toolbox_pin.gif]

Notice the Solution Explorer on the right side of your screen. (If you can't see the Solution Explorer, click its entry on the View menu at the top of Visual Studio Express.) If you compare it with the Solution Explorer when you created your Console Application, you can see the similarities:

[صورة مرفقة: solution_explorerA.gif]   [صورة مرفقة: solution_explorerB.gif]

Both projects have sections for Properties, References, and a Program.cs file. Double click the Program.cs file to open it, and you'll see some familiar code:

[صورة مرفقة: program_file_code.gif]

And here's the code from the Console Application:

[صورة مرفقة: program_file_code2.gif]

Both have the same using lines, a namespace, a class called Program, and a Main Method.

The Main Method is the entry point for your programme. The code between the curly brackets of Main will get executed when the programme first starts. The last line in the WindowsApplication1code above is the one that Runs Form1 when the Application starts.

You can do other things here. For example, suppose you had a programme that connects to a server. If it finds a connection then it loads some information from a database. In the Main Method, you could check that the server connection is OK. If it's not, display a second form; if it's OK, then display the first form.

But don't worry if all that code has you scratching your head. The thing to bear in mind here is that a method called Main starts your programme. And Program.cs in the Solution Explorer on the right is where the code for Main lives.

But we won't be writing code in the Program.cs file, so we can close it. Have a look near the top of the coding window, and you'll some tabs:

[صورة مرفقة: tabs_at_top.gif]

Click the X to close the tab. You should now see your form again (you may have a Start tab as well. You can close this, if you want).

To see the window where you'll write most of your code, right click Form1.cs in the Solution Explorer:

[صورة مرفقة: view_code.gif]

The menu has options for View Code and View Designer. The Designer is the Form you can see at the moment. Click View Code from the menu to see the following window appear (you can also press the F7 key on your keyboard in Community 2015, and CTRL + ALT + 0 in version 2012/13):


This is the code for the Form itself (ignore the Form1_Load lines as you may not have them). This Form:

[صورة مرفقة: form_view.gif]

The code has a lot more using statements than before. Don't worry about these for now. They just mean "using some code that's already been written".

The code also says partial class Form1. It's partial because some code is hidden from you. To see the rest of it (which we don't need to alter), click the arrow symbol next to Form1.cs in the Solution Explorer:

[صورة مرفقة: form_designer_sol_expl.gif]

Now double click Form1.Designer.cs. You'll see the following code:


Again, you see partial class Form1, which is the rest of the code. Click the plus symbol next toWindows Form Designer generated code. You'll see the following: (The code is from Visual Studio Express 2013. Community 2015 users won't see as much code.)


InitializeComponent is code (a Method) that is automatically generated for you when you create a new Windows Application project. As you add things like buttons and text boxes to your form, more code will be added here for you.

But you don't need to do anything in this window, so you can right click the Form1.Designer.cstab at the top, and click Close from the menu. Or just click the X.

Click back on the Form1.cs tab at the top to see you form again. If the tab is not there, right click Form1.cs in the Solution Explorer on the right. From the menu, select View Designer. Here's what you should be looking at:

[صورة مرفقة: form_view.gif]

It's in Designer view that we'll be adding things like buttons and text boxes to our form. But you can run this programme as it is. From the Debug menu at the top, click Start Debugging (Or you can just press the F5 key on your keyboard.):


When you click Start Debugging, Visual C# will Build the programme first, and then run it, if it can. If it can't run your programme you'll see error messages.

But you should see your form running on top of Visual Studio. It will have its own Red X, and it's own minimize and maximize buttons. Click the Red X to close your programme, and to return to Visual C# Express.

From now on, when we say Run your programme, this is what we mean: either press F5, or clickDebug > Start Debugging. You can also select Debug > Start Without Debugging.

OK, time for you to start adding things to the form, and to do a little coding!
سبحان الله والحمدلله ولا إله إلا الله والله أكبر
 اللهم اغْفِرْ لِلمؤمنين والمؤمنات والمسلمين والمسلمات الأحياء منهم والأموات
الرد }}}
#2
مشكور ابو عمر
في انتظار الدرس القادم

جعله الله في ميزان حسناتك...
الرد }}}
تم الشكر بواسطة: أبو عمر
#3
يعطيك العافية ابو عمر ..

بس افضل لو كان الكلام عربي ، لان هناك ناس ضعيفة في الانجليزي
وايضا لاتنسى اسم المنتدى فيجوال بيسك العرب Smile
الرد }}}
تم الشكر بواسطة: أبو عمر
#4
السلام عليكم


يعطيك العافية ابو عمر

.
Abu Ehab : Microsoft Partner  & Systems Developer
 Youtube   Facebook    Twitter   
الرد }}}
تم الشكر بواسطة: أبو عمر
#5
شكرا على الموضوع الاكثر من رائع 












_______________________________________________
التسامح الحق لا يستلزم نسيان الماضي بالكامل..

سينما كلوب
ايجي بست
شاهد فور يو

سيرا اون لاين


مشاهدة فيلم
الرد }}}
تم الشكر بواسطة: elgokr


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم