radioButton 事件处理

bfas2010 2013-01-24 03:27:02
这是代码:

这是初始化的界面:

这是全部可见的界面:

VIp为radioButton1 普通用户为 radioButton2
点击VIP时,没反应。中间两张图片不会显示。如何解决?
还有,这个窗口运行时,为何会有个DOS窗口弹出?以前写的其它窗口程序没DOS窗口弹出。
...全文
410 15 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
bfas2010 2013-01-25
  • 打赏
  • 举报
回复
呵呵,问题已经解决,,可能是VS2012 的问题。 响应事件的方法 如: private void radioButton1_CheckedChanged(object sender, EventArgs e) { } 这部分代码 若自己手动敲出来,就会失效。 在页面布局文件中,双击相应的控件。自动生成的这部分代码(再向里面添加具体内容),才能运行。 不知道你们的VS 是不是这样。 感谢楼上的各位,尤其是2楼和10楼。
Csharp_琪 2013-01-24
  • 打赏
  • 举报
回复
在Chenged事件里面再做一次Changed判断,然后再改变按钮的可视性~
a1668645906 2013-01-24
  • 打赏
  • 举报
回复
学习中......
bfas2010 2013-01-24
  • 打赏
  • 举报
回复
难道是VS 的问题? 不过其他的程序都能正常运行。我没改过任何地方的参数。 我在8楼 贴出来的验证程序,是重新新建的的一个工程,还是失败了。 ………………
bfas2010 2013-01-24
  • 打赏
  • 举报
回复
Click事件还是不行。
  • 打赏
  • 举报
回复
给radiobutton直接加click事件就行了 private void radioButton_Click(object sender, EventArgs e) { button1.Visible = !(button2.Visible = !button2.Visible); }
DENQH 2013-01-24
  • 打赏
  • 举报
回复
直接用Click事件,其中判断一下就可以了,不要用Chenged事件。
bfas2010 2013-01-24
  • 打赏
  • 举报
回复
我已经做了最简单的测试,还是不行。



这两种点击单选按钮还是没反应。
bookc-man 2013-01-24
  • 打赏
  • 举报
回复
楼主,单步执行过没???单步执行看看吧
config_man 2013-01-24
  • 打赏
  • 举报
回复

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            this.radioButton2.Checked = true;
            this.button3.Visible = false;
            this.button4.Visible = false;
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            this.button3.Visible = true;
            this.button4.Visible = true;
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            this.button3.Visible = false;
            this.button4.Visible = false;
        }
    }
我试了下,没问题。难道因为楼主设置了Location导致的?
bfas2010 2013-01-24
  • 打赏
  • 举报
回复
弹出DOS框的问题解决了。 把Form1_Load()内部的代码都注释掉,出现第二张图的的情况,点击普通用户,依然无效。
liangrf782533655 2013-01-24
  • 打赏
  • 举报
回复
弹DOS框是因为你 设置的output type是Console.Application.你把点击右键->property->output type拉框处选Windows.Application就行了。 击VIP时,没反应。中间两张图片不会显示,这个问题,与你的Form1_Load()方法有关,你无论点击哪儿个radio好像都调用了这个方法,
bfas2010 2013-01-24
  • 打赏
  • 举报
回复
1.将48 行到 57 行注释掉也一样,点击VIP没反应。 2.或改成下面的代码 点击VIP也无效。 private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked == true) { SetVisible(true); button1.Location = new Point(12, 65); button3.Location = new Point(105, 65); button5.Location = new Point(198, 65); button2.Location = new Point(12, 157); button4.Location = new Point(105, 157); button6.Location = new Point(198, 157); } } private void radioButton2_CheckedChanged(object sender, EventArgs e) { if (radioButton2.Checked == true) { button1.Location = new Point(12, 65); button3.Location = new Point(105, 65); button5.Location = new Point(198, 65); button2.Location = new Point(12, 157); button4.Location = new Point(105, 157); button6.Location = new Point(198, 157); SetVisible(false); } } 3.为啥这个窗口程序,运行时会弹出相应的DOS窗口?
config_man 2013-01-24
  • 打赏
  • 举报
回复
楼主还是取他们的状态再判断吧。
bdmh 2013-01-24
  • 打赏
  • 举报
回复
你出发radio1的时候,radio2的值也会变,就会触发radio2的事件,将两个按钮隐藏了

111,093

社区成员

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

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

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