1条回答
- threenewbee 2018-11-12 15:53关注
可以,看下面
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Q712947 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { for (int i = 0; i < 5; i++) listBox1.Items.Add(i); } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex > 0) { textBox1.Text = listBox1.SelectedIndex.ToString(); textBox2.Text = listBox1.Items[listBox1.SelectedIndex].ToString(); } } private void button1_Click(object sender, EventArgs e) { listBox1.Items[int.Parse(textBox1.Text)] = textBox2.Text; } } }
解决 3无用