本文整理汇总了C#中System.Windows.Forms.Binding类的典型用法代码示例。如果您正苦于以下问题:C# Binding类的具体用法?C# Binding怎么用?C# Binding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Binding类属于System.Windows.Forms命名空间,在下文中一共展示了Binding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BarEditItemTextBinding
public BarEditItemTextBinding(BarEditItem control, object dataSource, string dataMember)
{
_control = control;
_binding = new Binding("EditValue", dataSource, dataMember);
DataBindings.Add(_binding);
_control.EditValueChanged += _control_EditValueChanged;
}
示例2: ShredHostClientComponentControl
/// <summary>
/// Constructor
/// </summary>
public ShredHostClientComponentControl(ShredHostClientComponent component)
:base(component)
{
InitializeComponent();
_component = component;
// TODO add .NET databindings to _component
// create a binding that will show specific text based on the boolean value
// of whether the shred host is running
Binding binding = new Binding("Text", _component, "IsShredHostRunning");
binding.Parse += new ConvertEventHandler(IsShredHostRunningParse);
binding.Format += new ConvertEventHandler(IsShredHostRunningFormat);
_shredHostGroupBox.DataBindings.Add(binding);
Binding binding2 = new Binding("Text", _component, "IsShredHostRunning");
binding2.Parse += new ConvertEventHandler(IsShredHostToggleButtonParse);
binding2.Format += new ConvertEventHandler(IsShredHostToggleButtonFormat);
_toggleButton.DataBindings.Add(binding2);
_shredCollectionTable.Table = _component.ShredCollection;
_shredCollectionTable.SelectionChanged += new EventHandler(OnShredTableSelectionChanged);
_shredCollectionTable.ToolStripItemDisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
_shredCollectionTable.ToolbarModel = _component.ToolbarModel;
_shredCollectionTable.MenuModel = _component.ContextMenuModel;
_toggleButton.Click += delegate(object source, EventArgs args)
{
_component.Toggle();
};
}
示例3: AviExportAdvancedComponentControl
public AviExportAdvancedComponentControl(AviExportAdvancedComponent component)
:base(component)
{
_component = component;
InitializeComponent();
base.AcceptButton = _buttonOk;
base.CancelButton = _buttonCancel;
_checkUseDefaultQuality.DataBindings.Add("Checked", _component, "UseDefaultQuality", true, DataSourceUpdateMode.OnPropertyChanged);
_checkUseDefaultQuality.DataBindings.Add("Enabled", _component, "UseDefaultQualityEnabled", true, DataSourceUpdateMode.OnPropertyChanged);
_comboCodec.DataSource = _component.CodecInfoList;
_comboCodec.DisplayMember = "Description";
_comboCodec.DataBindings.Add("Value", _component, "SelectedCodecInfo", true, DataSourceUpdateMode.OnPropertyChanged);
_trackBarQuality.DataBindings.Add("Enabled", _component, "QualityEnabled", true, DataSourceUpdateMode.OnPropertyChanged);
_trackBarQuality.DataBindings.Add("Minimum", _component, "MinQuality", true, DataSourceUpdateMode.OnPropertyChanged);
_trackBarQuality.DataBindings.Add("Maximum", _component, "MaxQuality", true, DataSourceUpdateMode.OnPropertyChanged);
_trackBarQuality.DataBindings.Add("Value", _component, "Quality", true, DataSourceUpdateMode.OnPropertyChanged);
_quality.DataBindings.Add("Enabled", _component, "QualityEnabled", true, DataSourceUpdateMode.OnPropertyChanged);
Binding binding = new Binding("Text", _component, "Quality", true, DataSourceUpdateMode.OnPropertyChanged);
binding.Format += new ConvertEventHandler(OnFormatQuality);
_quality.DataBindings.Add(binding);
}
示例4: BindValueChanged
// We need to force WriteValue() on CheckedChanged otherwise it will only call WriteValue()
// on loss of focus.
// http://stackoverflow.com/questions/1060080/databound-winforms-control-does-not-recognize-change-until-losing-focus
/// <summary>
/// Binds the specified NumericUpDown control
/// </summary>
/// <param name="num"></param>
/// <param name="b"></param>
/// <returns></returns>
public static Binding BindValueChanged(NumericUpDown num, Binding b)
{
num.DataBindings.Add(b);
num.ValueChanged += (sender, e) => { b.WriteValue(); };
return b;
}
示例5: AddCore
protected virtual void AddCore (Binding dataBinding)
{
CollectionChangeEventArgs args = new CollectionChangeEventArgs (CollectionChangeAction.Add, dataBinding);
OnCollectionChanging (args);
base.List.Add(dataBinding);
OnCollectionChanged (args);
}
示例6: BindToObject
internal BindToObject(Binding owner, object dataSource, string dataMember)
{
this.owner = owner;
this.dataSource = dataSource;
this.dataMember = new System.Windows.Forms.BindingMemberInfo(dataMember);
this.CheckBinding();
}
示例7: BindSelectedIndexChanged
// We need to force WriteValue() on SelectedIndexChanged otherwise it will only call WriteValue()
// on loss of focus.
// http://stackoverflow.com/questions/1060080/databound-winforms-control-does-not-recognize-change-until-losing-focus
/// <summary>
/// Binds the specified combobox
/// </summary>
/// <param name="cmb"></param>
/// <param name="b"></param>
/// <returns></returns>
public static Binding BindSelectedIndexChanged(ComboBox cmb, Binding b)
{
cmb.DataBindings.Add(b);
cmb.SelectedIndexChanged += (sender, e) => { b.WriteValue(); };
return b;
}
示例8: Options
public Options()
{
InitializeComponent();
var bind = new Binding("Value", Properties.Settings.Default, "Opacity");
bind.Format += (sender, e) => { e.Value = (int)Math.Round((double)e.Value * 100); };
opacityTrackBar.DataBindings.Add(bind);
opacityTrackBar.ValueChanged += delegate
{
Properties.Settings.Default.Opacity = opacityTrackBar.Value / 100.0;
};
//controlCheckBox.CheckedChanged += delegate
//{
// Properties.Settings.Default.Control = controlCheckBox.Checked;
//};
//shiftCheckBox.CheckedChanged += delegate
//{
// Properties.Settings.Default.Shift = shiftCheckBox.Checked;
//};
//altCheckBox.CheckedChanged += delegate
//{
// Properties.Settings.Default.Alt = altCheckBox.Checked;
//};
//keyComboBox.TextChanged += delegate
//{
// Properties.Settings.Default.Key = keyComboBox.Text;
//};
}
示例9: CtorNullTest
public void CtorNullTest ()
{
Binding b = new Binding (null, null, null);
Assert.IsNull (b.PropertyName, "ctornull1");
Assert.IsNull (b.DataSource, "ctornull2");
}
示例10: Remove
protected internal void Remove(Binding binding)
{
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Remove, binding);
this.OnCollectionChanging(e);
this.RemoveCore(binding);
this.OnCollectionChanged(e);
}
示例11: Add
protected internal void Add(Binding binding)
{
CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Add, binding);
this.OnCollectionChanging(e);
this.AddCore(binding);
this.OnCollectionChanged(e);
}
示例12: Bind
public void Bind(object model_, string propertyOnModel_, Validators.IValidator validator_, bool colourNegRed_)
{
System.Windows.Forms.Binding binding;
binding = new System.Windows.Forms.Binding("Text", model_, propertyOnModel_, validator_ != null, DataSourceUpdateMode.OnPropertyChanged);
if (validator_ != null)
{
binding.Parse += new ConvertEventHandler(validator_.Parse);
binding.Format += new ConvertEventHandler(validator_.Format);
if (colourNegRed_ && validator_ is Validators.ISignChanged)
{
UseAppStyling = false;
m_validator = validator_;
ForeColor = System.Drawing.Color.Red;
((Validators.ISignChanged)validator_).SignChanged += handleSignChanged;
((Validators.ISignChanged)validator_).FireOnSignChanged();
}
}
if (DataBindings["Text"] != null)
DataBindings.Remove(DataBindings["Text"]);
DataBindings.Add(binding);
}
示例13: build
private void build(int row, int col)
{
string id = row.ToString() + col.ToString();
int x = INIT_HORZ_PADDING + (UPDOWN_SIZE.Width + LBL_SIZE.Width + HORZ_PADDING) * col;
int y = INIT_VERT_PADDING + (Math.Max(UPDOWN_SIZE.Height, LBL_SIZE.Width) + VERT_PADDING) * row;
GenotypeCount data = (GenotypeCount)_dataBS.DataSource;
bool isHomo = data.Genotype.IsHomozygous;
// Initialize the Label
_label = new Label() {
Name = $"{(isHomo ? "Homo" : "Hetero")}CountLbl{id}",
Location = new Point(x, y + LBL_OFFSET),
AutoSize = false,
Size = LBL_SIZE,
};
Binding lblBinding = new Binding("Text", _dataBS, "Genotype.Alleles", true, DataSourceUpdateMode.Never);
lblBinding.Format += LblBinding_Format;
_label.DataBindings.Add(lblBinding);
// Initialize the NumericUpDown
_upDown = new NumericUpDown() {
Name = $"{(isHomo ? "Homo" : "Hetero")}CountUpDown{id}",
Location = new Point(x + LBL_SIZE.Width, y),
Size = UPDOWN_SIZE,
Maximum = 100000m, // 100,000
Minimum = 0m,
TabIndex = row,
Value = 100m,
ThousandsSeparator = true,
};
Binding countBinding = new Binding("Value", _dataBS, "Count", false, DataSourceUpdateMode.OnPropertyChanged);
_upDown.DataBindings.Add(countBinding);
}
示例14: MouseImageViewerToolPropertyComponentControl
public MouseImageViewerToolPropertyComponentControl(MouseImageViewerToolPropertyComponent component)
{
InitializeComponent();
_chkInitiallySelected.DataBindings.Add("Checked", component, "InitiallyActive", false, DataSourceUpdateMode.OnPropertyChanged);
_cboActiveMouseButtons.Format += OnCboActiveMouseButtonsFormat;
_cboActiveMouseButtons.SelectedIndexChanged += OnComboBoxSelectedItemChangedUpdate;
_cboActiveMouseButtons.Items.Add(XMouseButtons.Left);
_cboActiveMouseButtons.Items.Add(XMouseButtons.Right);
_cboActiveMouseButtons.Items.Add(XMouseButtons.Middle);
_cboActiveMouseButtons.Items.Add(XMouseButtons.XButton1);
_cboActiveMouseButtons.Items.Add(XMouseButtons.XButton2);
_cboActiveMouseButtons.SelectedIndex = 0;
_cboActiveMouseButtons.DataBindings.Add("SelectedItem", component, "ActiveMouseButtons", true, DataSourceUpdateMode.OnPropertyChanged);
_cboGlobalMouseButtons.Format += OnCboActiveMouseButtonsFormat;
_cboGlobalMouseButtons.SelectedIndexChanged += OnComboBoxSelectedItemChangedUpdate;
_cboGlobalMouseButtons.Items.Add(XMouseButtons.None);
_cboGlobalMouseButtons.Items.Add(XMouseButtons.Left);
_cboGlobalMouseButtons.Items.Add(XMouseButtons.Right);
_cboGlobalMouseButtons.Items.Add(XMouseButtons.Middle);
_cboGlobalMouseButtons.Items.Add(XMouseButtons.XButton1);
_cboGlobalMouseButtons.Items.Add(XMouseButtons.XButton2);
_cboGlobalMouseButtons.SelectedIndex = 0;
_cboGlobalMouseButtons.DataBindings.Add("SelectedItem", component, "GlobalMouseButtons", true, DataSourceUpdateMode.OnPropertyChanged);
Binding keyModifierBinding = new Binding("KeyModifiers", component, "GlobalModifiers", true, DataSourceUpdateMode.OnPropertyChanged);
keyModifierBinding.Format += OnKeyModifierBindingConvert;
keyModifierBinding.Parse += OnKeyModifierBindingConvert;
_chkGlobalModifiers.DataBindings.Add(keyModifierBinding);
}
示例15: CreateCheckEditInverseBinding
public static Binding CreateCheckEditInverseBinding(string propertyName, object dataSource, string dataMember)
{
Binding bind = new Binding(propertyName, dataSource, dataMember);
bind.FormattingEnabled = true;
bind.Format += new ConvertEventHandler(BindingHelper.Invert);
bind.Parse += new ConvertEventHandler(BindingHelper.Invert);
return bind;
}