JBTALKS.CC

标题: (分享) Visual c# 教學 [打印本页]

作者: 狂天使    时间: 2011-6-2 11:30 AM
标题: (分享) Visual c# 教學
本帖最后由 狂天使 于 2011-6-2 11:36 AM 编辑

最近本人在學C#, 也希望這份文章能幫到想學C#的朋友。

也希望各位大大給些指教哦!

Lesson 1 : Create a windows form and  First Program
Go to http://www.microsoft.com/express/Downloads/ download the visual C# 2010 Express

1)  Click the new project


2) Choose Windows Form Application and Click Ok at the bottom

3) Introduce some basic tools



A) Toolbox: Use to design the Windows Form (Ctrl+W+X)
B) Solution Explorer: Can see the Project u create (Ctrl+W+S)
C) Properties:  Windows form properties (Ex: change font size, Name, size, etc) (Ctrl+W+P)
D) Start Debugging: Use to debug the project you create. (F5)

4) Now start our first program

A) Go to the toolbox -> Common Controls -> Button drag to the form. You can use your mouse  
           resize the button directly or go to Properties->Size to resize your button. The 1st value is width
          2nd value is height.



B) Double Click the button1 on Windows Form. Type this [MessageBox.Show(“Hello World”);] in the
     button_Click. If you want to know more detail of [MessageBox.Show] can surf this link
     http://msdn.microsoft.com/library/default.aspx . [MessageBox.Show] Display a message  
     box .(Simple Explain)



C) Click the Start Debugging(F5), and click the button1 it will appear the MessageBox Hello World. The result will same to above picture.

5) The Project will Store in Document-> Visual Studio 2010 -> Project. You can change your location also, go to File->Save All or CTRL+SHIFT+S.

Name: The Project Name
Location: The location that you store the project.

6) So how to let the project be .exe file (.exe file can directly run the program on the Windows).
1) After saving the project you can go to the Menu Bar Debug->Build Solution (F6) then will  
     generate the .exe file.
2) The .exe file will store in the “Your Project folder”->bin->Debug after generate. Double Click
     the .exe file, it will directly run the program.



END

英文也不是很好,如果Grammar 有錯的話也可以指針我。謝謝各位!
作者: david6629    时间: 2011-6-2 02:52 PM
加油=]

作者: 狂天使    时间: 2011-6-2 07:17 PM
Lesson 2: GUI Design

1) Start the new project Windows Forms Application


2) Design the GUI of the Windows of Application, can use the toolbox to design.


   A) Design the button (Toolbox->Common Control-> button) Click and drag on the windows form
   B)  Design the check box (Toolbox->Common Control-> check box ) Click and drag on the windows form


C) Design the Menu Bar (Toolbox-> Menu & Toolbars -> MenuStrip) Click and drag on the windows form you can type the name you want in the column.


D) Design the Status strip at bottom (Toolbox-> Menu & Toolbars -> Status_Strip) Click and drag on the windows form , have the drop down list after click the status strip button.



END
作者: 宅男-兜着走    时间: 2011-6-2 07:37 PM
不喜欢 winform, 喜欢 WPF 多一点。 比较接近网页的写法。
用起来比较舒服。
作者: Johnlai    时间: 2011-6-3 05:16 AM
想请问下这个和vb的分别在哪里啊?也是window form的~感觉很相似哦
作者: ~Zero    时间: 2011-6-3 10:33 AM
不喜欢 winform, 喜欢 WPF 多一点。 比较接近网页的写法。
用起来比较舒服。
宅男-兜着走 发表于 2011-6-2 07:37 PM

给初学者的话,还是 winform 比较适合做教学。
作者: ~Zero    时间: 2011-6-3 10:35 AM
想请问下这个和vb的分别在哪里啊?也是window form的~感觉很相似哦
Johnlai 发表于 2011-6-3 05:16 AM

其实大同小异的。coding syntax 和一些 built-in library 不同而已。
作者: 宅男-兜着走    时间: 2011-6-4 12:14 AM
回复 6# ~Zero


    当考虑使用一个技术来做production 的时候, 就要想这些控件, language 适不适合用在你的IDEA 上。
然而我觉得winform 很难下。 不花些时间, 不投点钱买component, 很难作出好的东西。

虽然 drag and drop 是很好

不过他会那么快遗忘一定是有某些原因的。==
作者: Grazio-int    时间: 2011-6-4 05:03 PM
多谢分享。
作者: goodhermit95    时间: 2011-6-4 11:11 PM
我用WPF的时候,想要用一些class library,就没有...
作者: 宅男-兜着走    时间: 2011-6-5 01:28 AM
回复 10# goodhermit95


    你用winform 的时候SKIN得到酱的 UI 吗?
     
作者: goodhermit95    时间: 2011-6-6 11:23 PM
我知道winform的skin输了,但是用wpf就是不顺手,想要用的class要自己写一堆api...
我并不是支持winform,可以说是我的wpf很差
作者: 狂天使    时间: 2011-6-7 02:55 PM
各位各位,不需要為了這些小小的事情爭的喋喋不休啊。

其實不管是喜歡 Winform 或者是 WPF,都是個人的選擇,只要自己習慣和喜歡就好了。而且,這也是我第一次做教學文章,如果有什麼疏漏之處也請各位大大給些批評指教!只是,希望能幫到一些想學Visual C# 和 winform 的朋友。畢竟我也還是新人,還在學習當中!

當然,要先謝謝各位大大給我的一些批評,能讓我能持續的進步。我可是還有很多進步的空間,呵呵!!
  1. :):)
复制代码

作者: ~Zero    时间: 2011-6-7 04:36 PM
回复  goodhermit95


    你用winform 的时候SKIN得到酱的 UI 吗?
宅男-兜着走 发表于 2011-6-5 01:28 AM

winform 的 skin 只要愿意花钱 / 时间,也可以弄到很漂亮的。
再说,这个毕竟也都是教学帖,给新人学习的话,不必太在乎 UI 吧。

各有各的好坏。如果只是要写个 calculator,wpf 简直是多余。
作者: goodhermit95    时间: 2011-6-7 05:36 PM
winform 的 skin 只要愿意花钱 / 时间,也可以弄到很漂亮的。
再说,这个毕竟也都是教学帖,给新人学习的 ...
~Zero 发表于 2011-6-7 04:36 PM



    讲真的.net winform 你放太多skin 很多工 会一直闪
要double buffer 要很长很长的code
作者: 圻小弟xD    时间: 2011-6-7 05:49 PM
谢谢,我下载了就是不会用
作者: ~Zero    时间: 2011-6-7 06:21 PM
讲真的.net winform 你放太多skin 很多工 会一直闪
要double buffer 要很长很长的code{:1_448: ...
goodhermit95 发表于 2011-6-7 05:36 PM

http://www.telerik.com/products/winforms.aspx
看看人家的漂亮的 winform demo 吧。
作者: 宅男-兜着走    时间: 2011-6-7 07:53 PM
回复 17# ~Zero


    telerik 的控件要钱
    不过小教程也能 WPF 的也是 drag and drop, 没什么差别。

    不过skin 得美不美也是多余  能用就好。
作者: 宅男-兜着走    时间: 2011-6-7 07:56 PM
回复 13# 狂天使


   抱歉,我比较极端
   我只是觉得用得顺手而已。
   
   我也不过是菜菜。 进来玩玩下骗分数
作者: 宅男-兜着走    时间: 2011-6-7 07:57 PM
回复 12# goodhermit95

听说 wpf 要 net 3.5++
跟你要脱离 net 的理想差很远
作者: goodhermit95    时间: 2011-6-8 12:47 PM
脱离.net的理想...
讲真的我不用什么skin
我觉得dwmapi就已经很美了
.net 3.5好想200多MB 网友要用我不超过1MB的小软件去下载那个真的会疯掉
作者: no7z    时间: 2011-6-9 07:41 AM
懂的原理即可 C#和C++或是java 都是工具而已




欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/) Powered by Discuz! X2.5