C#实现在坐标上画点,怎么实现?
privatevoidTextBox1_KeyDown(objectsender,KeyEventArgse){if(e.KeyCode==Keys.Enter){int...
private void TextBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
int x,y = int.Parse(textBox1.Text);
Point point =newPoint(x,y);
Graphics g = Panel.CreateGraphics();
g.FillEllipse(Brushes.Red,newRectangle());
}
如上代码 按回车后显示点 怎么修改它 求大神 焦急等待着 展开
{
if (e.KeyCode == Keys.Enter)
{
int x,y = int.Parse(textBox1.Text);
Point point =newPoint(x,y);
Graphics g = Panel.CreateGraphics();
g.FillEllipse(Brushes.Red,newRectangle());
}
如上代码 按回车后显示点 怎么修改它 求大神 焦急等待着 展开
2个回答
展开全部
//在textbox输入10,10并回车注意中间是英文逗号
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
string[] ss = textBox1.Text.Trim().Split(new char[] { ',' });
int x = Convert.ToInt32(ss[0]);
int y = Convert.ToInt32(ss[1]);
Graphics g = textBox1.CreateGraphics();
g.FillEllipse(Brushes.Red, new Rectangle(0, 0, x, y));
}
}
追问
g.FillEllipse(Brushes.Red, new Rectangle(0, 0, x, y));中括号里的0,0,x,y 是什么意思?
int x = Convert.ToInt32(ss[0]);
int y = Convert.ToInt32(ss[1]);怎么理解??
追答
以逗号拆分输入的整数对,分别做长宽,矩形的默认起点是0,0
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询