c#中,设计一个窗口,建立坐标系图表

anshoulei 2011-04-08 04:03:09
我已经编写了如下c#代码,功能是显示一个窗口,输入一个i值,点击button1输出一个l值,
点击button2输出一个content[i]值,
namespace WindowsApplication1
{
public partial class Form1 : Form
{
int i;

public Form1()
{
InitializeComponent();
}



private void button1_Click_1(object sender, EventArgs e)
{

i = int.Parse(textBox1.Text);
double l = ((double)4000 / 20480) * i;
textBox2.Text = l.ToString();

}

private void button2_Click(object sender, EventArgs e)
{
string[] content = System.IO.File.ReadAllLines(@"D:\ccc.txt");
if (textBox1.Text == string.Empty || i> 20480)
{
MessageBox.Show("输入不完整!");
return;
}
textBox3.Text = content[i];


}


现在我想建立一个坐标系,横坐标为l,纵坐标为content[i],我该怎么写呢?多谢了!!!
...全文
310 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
diy2005 2011-05-02
  • 打赏
  • 举报
回复
Pen redPen = new Pen(Color.Red, 1);
Pen bluePen = new Pen(Color.Blue, 2);
Pen greenPen = new Pen(Color.Green, 3);
Pen blackPen = new Pen(Color.Black, 4);

Graphics g = this.CreateGraphics();
//g.SmoothingMode = SmoothingMode.AntiAlias;

// 使用浮点坐标绘制直线
float x1 = 20.0F, y1 = 20.0F;
float x2 = 200.0F, y2 = 20.0F;
g.DrawLine(redPen, x1, y1, x2, y2);

// 使用Point结构体绘制直线
Point pt1 = new Point(20, 20);
Point pt2 = new Point(20, 200);
g.DrawLine(greenPen, pt1, pt2);

// 使用PointF结构体绘制直线
PointF ptf1 = new PointF(20.0F, 20.0F);
PointF ptf2 = new PointF(200.0F, 200.0F);
g.DrawLine(bluePen, ptf1, ptf2);

// 使用整数坐标绘制直线
int X1 = 60, Y1 = 40, X2 = 250, Y2 = 100;
g.DrawLine(blackPen, X1, Y1, X2, Y2);

// 释放对象
redPen.Dispose();
bluePen.Dispose();
greenPen.Dispose();
blackPen.Dispose();
anshoulei 2011-04-09
  • 打赏
  • 举报
回复
没人帮我啊!多谢各位大哥哥大姐姐了!

4,816

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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