62,271
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ComboBox C = new ComboBox();
C.Name = "comboBox1";
C.Location = new Point(20, 20);
this.Controls.Add(C);
comboBox1.Items.Add("第一项"); //这里有警告
comboBox1.Items.Add("第二项");
comboBox1.Items.Add("第三项");
comboBox1.Items.Insert(0, "后面插入一项");
comboBox1.SelectedIndex = 0;
}
}
}
DropDownList1.SelectedIndex = 0;
DropDownList1.SelectedValue=.....;