一个简单问题

digqq 2003-10-19 10:03:59
一个winform,两个按钮“button1”和“button2”,如何使在点击“button1”之后,disable的“button2”可用。也就是说,进入该winform之后,“button1”是灰的,不可点击,而必须在点击button2之后,button1才可用,谢谢!

还有一个白痴问题,在弹出的消息框里可以加图片的吗?我不会,谢谢大家帮忙。
...全文
40 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
digqq 2003-10-19
  • 打赏
  • 举报
回复
那我连起来问一个问题吧,点击“button2”之后先让它弹出消息框,我那个消息框是这样的MessageBox.Show("你确定吗?","消息",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
也就是说,点击"button2"之后,出来消息框,我点里面的“确定”之后,button1可用,我点“取消”,那么button1还是不可用,应该怎么写那个代码呢?
digqq 2003-10-19
  • 打赏
  • 举报
回复
to 第一楼,没有问题,谢谢
to 上楼,谢谢
abcynic 2003-10-19
  • 打赏
  • 举报
回复
2.调用MessageBoxIcon枚举,给你个例子。
MessageBox.Show("You must enter a name.", "Name Entry Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
digqq 2003-10-19
  • 打赏
  • 举报
回复
to wideroad() __报错了_______“System.Windows.Forms.Button”并不包含对“visible”的定义?

digqq 2003-10-19
  • 打赏
  • 举报
回复
不对,是两位,呵呵
digqq 2003-10-19
  • 打赏
  • 举报
回复
谢谢三位哈,我看看先

至于加图片,就像window经常弹出的警告消息框里面的那种小图片啊,表示警告,消息,提示什么的啊

就是这样
wideroad 2003-10-19
  • 打赏
  • 举报
回复
你在button2的单击事件里面写上这句话:
this.button1.Enabled = true;
this.button1.visible = true;
就行了
rgbcn 2003-10-19
  • 打赏
  • 举报
回复
你要加什么图片。
rgbcn 2003-10-19
  • 打赏
  • 举报
回复
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace rsgl
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(128, 56);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(128, 128);
this.button2.Name = "button2";
this.button2.TabIndex = 1;
this.button2.Text = "button2";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(512, 341);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button2,
this.button1});
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}
#endregion

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

private void Form1_Load(object sender, System.EventArgs e)
{
button1.Enabled = false ;
}

private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{

}

private void panel2_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{

}

private void button2_Click(object sender, System.EventArgs e)
{
button1.Enabled = true;
}
}
}

110,530

社区成员

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

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

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