请大家帮忙解决一下

赵自行 2010-09-12 10:37:11
我在C#的窗体应用程序中增加了一个botton控件,希望单击它的时候这个控件的text属性发生改变,并且功能发生改变。再单击一次又功能和text属性再变回到原来的样子,我是初学者,希望大家帮个忙,这是我的作业啊!
...全文
68 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangaijiang 2010-09-12
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 zhangaijiang 的回复:]
引用 1 楼 wuyq11 的回复:
bool f=false;
private Void button1_Click(object sender, EventArgs e)
{
Button btn=sender as Button;
btn.Text=f?"":"";
f=!f;
}


或者声明一个静态变量 static int num=0;
每点击一下num++
num%2
[/Quote]
if(整除){};if(有余数){}
zhangaijiang 2010-09-12
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyq11 的回复:]
bool f=false;
private Void button1_Click(object sender, EventArgs e)
{
Button btn=sender as Button;
btn.Text=f?"":"";
f=!f;
}
[/Quote]

或者声明一个静态变量 static int num=0;
num%2
kensouterry 2010-09-12
  • 打赏
  • 举报
回复

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int times = 0;

public Form1()
{
InitializeComponent();

Store st = new Store();
}

private void button1_Click(object sender, EventArgs e)
{
times++;
button1.Text=Store.GetButtonText(times);
}
}

class Store
{
static List<string> listText = new List<string>();

public Store()
{
listText.Add("Add new verb");
listText.Add("Enter");
}

public static string GetButtonText(int times)
{
if (times % 2 == 1)
{
return listText[1];
}
else
{
return listText[0];
}
}
}
}

还需要设置textBox的enabled属性!
porschev 2010-09-12
  • 打赏
  • 举报
回复
添加词汇那里可以放两个按钮。。确定放下面

添加之后。。这个添加按钮隐藏。。
赵自行 2010-09-12
  • 打赏
  • 举报
回复
当然功能大家应该都知道
赵自行 2010-09-12
  • 打赏
  • 举报
回复
赵自行 2010-09-12
  • 打赏
  • 举报
回复

我希望的目的是单击“添加新词汇”,它会变成“确定”;并且有个文本框的readonly属性变为false。
porschev 2010-09-12
  • 打赏
  • 举报
回复
其实可以放两个。。。两个放重叠。。

通过显示和隐藏来解决
wuyq11 2010-09-12
  • 打赏
  • 举报
回复
bool f=false;
private Void button1_Click(object sender, EventArgs e)
{
Button btn=sender as Button;
btn.Text=f?"":"";
f=!f;
}

110,567

社区成员

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

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

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