消息框包含表在C# [英] Message Box to contain Table in C#

查看:103
本文介绍了消息框包含表在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IEnumerable<string> peopleWithInvalidAge =
                    (from age in User
                     where age < 0
                     select name ).Distinct();

MessageBox.show("The people who have invalid age are {0}" , string.Join(", ", peopleWithInvalidAge) )

这显示为字符串输出。但我想的是,输出应显示在一个表格形式。随着姓名和年龄时的MessageBox.show被调用。

This displays the output as string . But what i want is that the output should be displayed in a tabular form . With Name and age when MessageBox.show is called.

如果我们可以在里面消息框,选中随后也将是巨大的。

If we can highlight inside message box then also it will be great

请帮忙。

推荐答案

这是为WPF

有关格式可以使用窗口。
你可以通过了IEnumerable的构造函数。
Window.ShowDialog是模态。

For formatting could use Window.
You can pass the IEnumerable in the ctor.
Window.ShowDialog is modal.

窗口。 ShowDialog方法

Window1 win = new Window1(new List<string> { "john", "susan" });
win.ShowDialog();

public Window1(IEnumerable<string> names)
{
    Names = names;
    InitializeComponent();
}
public IEnumerable<string> Names { get; private set; }

<Window x:Class="ListViewUpdate.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        DataContext="{Binding RelativeSource={RelativeSource self}}"
        Title="Window1" Height="300" Width="300">
<Grid>
    <ListView ItemsSource="{Binding Path=Names}" />
</Grid>
</Window>

主持人有三个部分质疑。
模态,传递数据和格式。
对方回答没有解决模式或将数据传递到一个窗口。
我张贴,而我是创造了传球和格式样本。

Moderator there are three parts to question.
Modal, passing data, and formatting.
The other answer does not address modal or passing data to a Window.
I posted while I was creating the passing and formatting sample.

这篇关于消息框包含表在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆