我正在学习数据绑定,我有一个带有一个属性的类,然后我有另一个带有组合框和2个值"1和2"的类,我已经用属性创建了我的类的数组对象,所以当组合框有1我的文本框会给它一个类[0] .property的值,相反,如果我有2这个发生在类[1] .property这里是代码,所以你会更好地理解:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication1
{
struct Class1
{
public string pollo { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
我的第二堂课:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Class1[] prova = new Class1[2];
int a;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
a = Convert.ToInt32(comboBox1.SelectedItem) - …
Run Code Online (Sandbox Code Playgroud) c# ×1