// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace E { public class Foobar { public int A { get; set; } public int B { get; set; } public int C { get; set; } } public partial class MainForm : Form { public MainForm() { InitializeComponent(); comboBox1.DataSource = new List>> { new Tuple>("Set A",(o,v)=>o.A=v), new Tuple>("Set B",(o,v)=>o.B=v), new Tuple>("Set C",(o,v)=>o.C=v) }; comboBox1.DisplayMember = "Item1"; comboBox1.ValueMember = "Item2"; } void Button1Click(object sender, EventArgs e) { Foobar o = new Foobar(); ((Action)comboBox1.SelectedValue).Invoke(o, int.Parse(textBox1.Text)); MessageBox.Show(o.A + "|" + o.B + "|" + o.C); } } }