云南特产 健康论坛 创业论坛 一树百花 低空飞行  
             

Trove

我更用力的振动翅膀! 只想飞得更高.

博客园 首页 新随笔 联系 订阅 管理
  14 Posts :: 0 Stories :: 10 Comments :: 0 Trackbacks

公告

2007年6月2日 #

You use System Reflection to dynamically load a control. If the DLL is named "RComponent.WinForm.DLL" and the class you want is "RComponent.WinForm.Tree", then use this code.
[C#]
     // load the assembly
     System.Reflection.Assembly assembly = Assembly.LoadFrom("RComponent.WinFormDLL");

     // get the type
     Type t = assembly.GetType("RComponent.WinForm.Tree");

     // create an instance and add it.
     //
     Control c = (Control)Activator.CreateInstance(t);
     parent.Controls.Add(c);


posted @ 2007-06-02 21:38 正午冰鱼 阅读(90) 评论(0) 编辑

Override the OnPaint. Here is some code for a derived Button.
[C#]
     public class MyButton : Button
     {
          protected override void OnPaint(PaintEventArgs e)
          {
               base.OnPaint(e);
               int borderWidth = 1;
               Color borderColor = Color.Blue;
               ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, borderColor,
                         borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth,
                         ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid,
                         borderColor, borderWidth, ButtonBorderStyle.Solid);
          }
     }
posted @ 2007-06-02 21:34 正午冰鱼 阅读(105) 评论(1) 编辑

               
  云南特产 健康论坛 创业论坛 淘宝客 低空飞行 网页目录  
               

To add a control at runtime, you do three steps:

  • 1. Create the control
  • 2. Set control properties
  • 3. Add the control to the Form's Controls collection

In general, if you need help on exactly what code you need to add, just look at the code generated by the designer when you add the control at design time. You can generally use the same code at runtime.

Here are code snippets that create a textBox at runtime.
[C#]
     //step 1
     TextBox tb = new TextBox();

     //step2
     tb.Location = new Point( 10, 10);
     tb.Size = new Size(100, 20);
     tb.Text = "I was created at runtime";

     //step3
     this.Controls.Add(tb);

[VB.NET]

     'step 1
     Dim tb as TextBox = New TextBox()

     'step2
     tb.Location = New Point( 10, 10)
     tb.Size = New Size(100, 20)
     tb.Text = "I was created at runtime"

     'step3
     Me.Controls.Add(tb)

 


 

posted @ 2007-06-02 21:31 正午冰鱼 阅读(231) 评论(1) 编辑

由于工作上的原因, 习惯了用英文, 很少写中文了,
所以前面连续几篇都是英文, 估计大家都不喜欢, 写了3天了, 一个回复了也没有, 真是郁闷.
我想多看多写 英文对提高英文很有好处的, 尤其是对于写程序, 有很多非常好的英文网站,    
有许多资料,看英文很明了,看中文, 真是不知所云, 不知道是不是我的语言区出了问题):
工作太忙, 今天竟然又要加班, 那个该死的je的问题没完没了,  好象用了我们的软件, 他所有的问题就找到了
我们帮助, 他要在这样, 非被这哥们累死不可, 本来要去西单买衣服的,被这哥们的加班搞没了.
下次带他去逛街好了. 
posted @ 2007-06-02 21:19 正午冰鱼 阅读(77) 评论(5) 编辑

             
  云南特产 健康论坛 创业论坛 一树百花 低空飞行