在C#中如何设置单击单选按钮后显示不同的pictureBox图片?
2个单选按钮,你单击第一个显示第一个pictureBox图片,单击第二个,显示第二个pictureBox图片,请各位大哥,帮忙看下,万分感谢,!!!...
2个单选按钮,你单击第一个显示第一个pictureBox图片,
单击第二个,显示第二个pictureBox图片,
请各位大哥,帮忙看下, 万分感谢,!!! 展开
单击第二个,显示第二个pictureBox图片,
请各位大哥,帮忙看下, 万分感谢,!!! 展开
展开全部
//新建一个Windwos窗体项目, 从工具箱拉两个RadioButton, 一个PictureBox,
//还有一个ImageList到窗体上,把两张图片加入到imagelist中;
//选中两个RadioButton控件(一定要一起选中), 找到Click事件, 点击一下进入代码
//其它的你看我以下的就好了.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication3 //此处你修改成你自己的命名空间
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = imageList1.Images[0];
}
private void radioButton1_Click(object sender, EventArgs e)
{
if (((RadioButton)sender).Name.ToString() == "radioButton1")
{
pictureBox1.Image = imageList1.Images[0];
}
else
{
pictureBox1.Image = imageList1.Images[1];
}
}
}
}
//还有一个ImageList到窗体上,把两张图片加入到imagelist中;
//选中两个RadioButton控件(一定要一起选中), 找到Click事件, 点击一下进入代码
//其它的你看我以下的就好了.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication3 //此处你修改成你自己的命名空间
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = imageList1.Images[0];
}
private void radioButton1_Click(object sender, EventArgs e)
{
if (((RadioButton)sender).Name.ToString() == "radioButton1")
{
pictureBox1.Image = imageList1.Images[0];
}
else
{
pictureBox1.Image = imageList1.Images[1];
}
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Test4_5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
pictureBox1.Image = Image.FromFile("d:\\a.jpg");
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
pictureBox1.Image =Image.FromFile("d:\\b.jpg");
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Test4_5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
pictureBox1.Image = Image.FromFile("d:\\a.jpg");
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
pictureBox1.Image =Image.FromFile("d:\\b.jpg");
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询