当前位置: 首页>>代码示例>>C#>>正文


C# Label.Bind方法代码示例

本文整理汇总了C#中System.Windows.Forms.Label.Bind方法的典型用法代码示例。如果您正苦于以下问题:C# Label.Bind方法的具体用法?C# Label.Bind怎么用?C# Label.Bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Label的用法示例。


在下文中一共展示了Label.Bind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LogForm_Load

        private void LogForm_Load(object sender, EventArgs e)
        {
            guiPanel.FlowDirection = FlowDirection.TopDown;
            guiPanel.Controls.Clear();
            Func<ProgressObject, Control> progressTemplate = (ProgressObject po) => {
                var topLabel = new Label() {
                    Margin = new Padding(0, 5, 0, 5),
                    Font = new Font(Font.FontFamily, 12f, FontStyle.Bold),
                    Width = guiPanel.Width - 30,
                    AutoSize = true
                };
                var botLabel = new Label() {
                    Width = guiPanel.Width - 30,
                    AutoSize = true
                };
                var progBar = new ProgressBar() {
                    Margin = new Padding(0, 5, 0, 0),
                    Width = guiPanel.Width - 30,
                    AutoSize = true
                };

                po.TaskTitle.Binding = topLabel.Bind(x => x.Text).ToBinding(BindingMode.FromTarget);
                po.TaskText.Binding = botLabel.Bind(x => x.Text).ToBinding(BindingMode.FromTarget);
                po.Total.Binding = progBar.Bind(x => x.Maximum).ToBinding(BindingMode.FromTarget);
                po.Current.Binding = progBar.Bind(x => x.Value).ToBinding(BindingMode.FromTarget);

                progBar.Maximum = po.Total.Value;
                progBar.Value = po.Current.Value;
                var flowThing = new FlowLayoutPanel() {
                    FlowDirection = FlowDirection.TopDown,
                    Margin = new Padding(10, 5, 10, 5),
                    Width = guiPanel.Width - 30

                };
                flowThing.Controls.AddRange(new[] {
                    (Control) topLabel,
                    botLabel,
                    progBar
                });
                return flowThing;
            };
            List.Binding =
                guiPanel.Controls
                .CastList().ProjectList(progressTemplate)
                .ToBindable()
                .WithDispatcher(act => Invoke(act))
                .ToBinding(BindingMode.FromTarget);
        }
开发者ID:GregRos,项目名称:Patchwork,代码行数:48,代码来源:LogForm.cs


注:本文中的System.Windows.Forms.Label.Bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。