protected void Bind(TrackBar tb, Label lbl, NetworkConfig config, string field) { Type t = config.GetType(); PropertyInfo pi = t.GetProperty(field, BindingFlags.Instance | BindingFlags.Public); int p = (int)pi.GetValue(config); tb.Value = p; lbl.Text = p.ToString(); tb.ValueChanged += (sender, args) => { p = tb.Value; lbl.Text = p.ToString(); pi.SetValue(config, p); }; }