是否可以在列表框的两行中添加texte中输入的相同字符串,如下图所示?
private void metroButton10_Click(object sender, EventArgs e)
{
listBox2.Items.Add("Next station: " + metroTextBox1.Text);
listBox2.Items.Add(Environment.NewLine)
metroTextBox1.Clear();
listBox2.SelectedIndex = 0;
}
答案 0 :(得分:2)
使用以下代码。
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add("Next Station: "+textBox1.Text);
listBox1.Items.Add("Station: " + textBox1.Text);
}
你不能使用新行。因为列表框可以在一行中包含一个项目。
答案 1 :(得分:2)
当然,您可以在列表框的两行中的文本框中添加相同的字符串;
#include<windows.h>
#include<glut.h>
GLfloat x1=100.0f;
GLfloat y1=150.0f;
GLsizei rsize = 50;
GLfloat xstep=1.0f;
GLfloat ystep=1.0f;
GLfloat windowWidth;
GLfloat windowHeight;
void scene(void){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f,0.0f,0.0f);
glRectf(x1,y1,x1+rsize,y1-rsize);
glutSwapBuffers();
}
void setupRc(void){
glClearColor(0.0f,0.0f,1.0f,0.0f);
}
void changeSize(GLsizei w,GLsizei h){
if(h==0)
h=1;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w>=h){
windowWidth=250.0f*w/h;
windowHeight=250.f;
}
else{
windowWidth=250.0f;
windowHeight=250.f*h/w;
}
glOrtho(0.0f,windowWidth,0.0f,windowHeight,1.0f,-1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void main(void){
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutCreateWindow("Rectangle");
glutReshapeFunc(changeSize);
glutDisplayFunc(scene);
setupRc();
glutMainLoop();
}