2012-07-28 69 views
1

我已经在C#中编程一年了。 我想制作一个自定义的Windows窗体。我已经搜遍了所有,无法得到答案。 据我所知,做这件事真的很难,很长时间以来,是否有人知道一个教程,教导从头创建一个自定义表单? 谢谢c#绘制自定义表格

+0

你是什么意思**自定义Windows窗体**? – hmmftg 2012-07-28 00:26:36

+0

尝试在Custom Window Chrome下搜索。并看看这[SO问题](http://stackoverflow.com/questions/42460/custom-titlebars-chrome-in-a-winforms-app)帮助/ – 2012-07-28 00:34:58

回答

0

你原来的问题根本不清楚。如果你只是想实例化一个Form类和Control派生类型来添加到它的控件集合中,那真的很容易。当您使用向导创建一个Visual Studio时,您只需要注意由Visual Studio生成的部分类。

根据你在下面的评论的最后一句话,这个代码可以是解决方案:

public partial class Form1 : CustomForm 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
     }    
    } 

    public class CustomForm : Form 
    {   
     public CustomForm() 
     { 
      this.Text = "your choice"; 
      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 
      //and so on...    
      //you may even implement your own private InitializeComponent() to instantiate your common child controls 
      //since this is a constructor with no arguments it will be used by derived types with no need to explicitly call it in their own 
     } 
    } 
+0

我想创建一个窗体,我可以自定义标题栏(颜色,高度等),并可以设置视觉属性,如背景颜色,没有边框,当我创建一个新的表单时,新的表单可以继承这个表单,所以从这个表单继承的所有表单具有相同的基本轮廓看(不是客户区)。 – 2012-07-28 23:10:47

+0

我刚刚改变了我的答案,以适应您的最后要求 – 2012-07-28 23:35:54

+0

谢谢你,真的帮了我 – 2012-07-30 09:46:19