button控件一段代码,没看懂,请朋友帮忙解释一下

badboy168 2005-05-24 06:38:30
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Resources;

public class ButtonCtl : System.Windows.Forms.Form
{ private System.Windows.Forms.Button button1; }

public ButtonCtl() : base()
{ InitializeComponent(); }

private void InitializeComponent()
{ System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ButtonCtl));

this.button1 = new System.Windows.Forms.Button();

this.Text = "按钮";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(504, 381);

button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
button1.Location = new System.Drawing.Point(32, 112);
button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
button1.Size = new System.Drawing.Size(136, 56);
button1.TabIndex = 5;
button1.Text = "TestButton";
button1.Click += new System.EventHandler(button1_Click);
button1.Image = (System.Drawing.Image)resources.GetObject("button1.Image");//这句是什么意思

this.Controls.Add(button1);
}

/// <summary>
/// 处理 button1.Click
/// </summary>
private void button1_Click(object sender, EventArgs e) {
MessageBox.Show("您已按下测试按钮") ;
}



/// <summary>
/// 该应用程序的主入口点。
/// </summary>
[STAThread]
public static void Main(string[] args) {
Application.Run(new ButtonCtl());
}

}


我的问题是button1.Image = (System.Drawing.Image)resources.GetObject("button1.Image");这句是什么意思,我理解为:取得button1.Image资源,再赋给button1.Image

我看了MSDN讲的ResourceManage没太明白什么意思,明朋友帮望解决一下
...全文
100 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
badboy168 2005-05-25
  • 打赏
  • 举报
回复
没明白,取提什么资源
alexxzr 2005-05-24
  • 打赏
  • 举报
回复
噢!!!
lulei 2005-05-24
  • 打赏
  • 举报
回复
看法同一楼
willsun 2005-05-24
  • 打赏
  • 举报
回复
resources.GetObject("button1.Image")含义为获取资源文件中资源名为"button1.Image"的资源

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧