【问题标题】:display two textbox in customMessageBox?在customMessageBox 中显示两个文本框?
【发布时间】:2013-08-14 13:51:29
【问题描述】:

好吧,我想在 customMessageBox 的 next 旁边显示两个文本框。所以我为两个文本框编码。如下所示。我为此命名了sooraayath。但是在customMessageBox 中,我不能同时调用两个文本框。它显示错误。如何在customMessageBox 的下一个旁边显示两个文本框。我只有错误,它是Content = soora + ayath

我的 C# 代码;

TextBox soora = new TextBox();
                soora.Height = 72;
                soora.Width = 150;
                soora.MaxLength = 3;

TextBox ayath = new TextBox();
                ayath.Height = 72;
                ayath.Width = 150;
                ayath.MaxLength = 3;

CustomMessageBox messageBox = new CustomMessageBox()
            {
                Title = "GO TO",
                Content = soora + ayath,
                RightButtonContent = "Go !",
            };

【问题讨论】:

  • 当您将文本框添加到文本框时,您期望得到什么?富文本框?不允许该操作。此外,向我们展示 Content(类型)和 CustomMessageBox 的定义。
  • 我需要输入表单用户。我需要 MessageBox 中的两个输入字段
  • 你能展示CustomMessageBox的实现吗? Content 是什么?
  • 我已经从here 安装了NuGet 并且只使用了customMessageBox

标签: c# messagebox


【解决方案1】:

使用container control 来保存textboxes

TextBox soora = new TextBox();
                soora.Height = 72;
                soora.Width = 150;
                soora.MaxLength = 3;

TextBox ayath = new TextBox();
                ayath.Height = 72;
                ayath.Width = 150;
                ayath.MaxLength = 3;

StackPanel container = new StackPanel{
                           Orientation = System.Windows.Controls.Orientation.Horizontal
                       };

container.Children.Add(soora);
container.Children.Add(ayath);    

CustomMessageBox messageBox = new CustomMessageBox()
            {
                Title = "GO TO",
                Content = container,
                RightButtonContent = "Go !",
            };

【讨论】:

    【解决方案2】:

    如果你想显示文本那么

    Content = soora.Text + ayath.Text,
    

    【讨论】:

    • 我需要输入表单用户。我需要 MessageBox 中的两个输入字段
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    • 2013-02-02
    • 1970-01-01
    相关资源
    最近更新 更多