【问题标题】:How can i generate listView base on date range?如何根据日期范围生成 listView?
【发布时间】:2013-04-12 11:38:43
【问题描述】:

我怎样才能根据日期范围做一个列表视图?

这件事有可能吗?

【问题讨论】:

  • 您是如何生成这些快照的?
  • @Jesson:您想要使用 listView 的任何具体原因。为什么不使用 Datagrid?
  • @David:我刚刚在 xaml 上写了。

标签: c# wpf listview


【解决方案1】:

在 XAML 中:

<ListView>
    <ListView.View>
        <GridView x:Name="myView">
        </GridView>
    </ListView.View>
</ListView>

在 YourForm.cs 中

private void CreateColumns()
{
    var startDate = new DateTime(2013, 05, 07);
    var endDate = new DateTime(2013, 05, 17);

    //// Ensure that startDate < endDate, no validation in this example.

    var tmp = startDate;
    while (tmp <= endDate)
    {
        GridViewColumn gc = new GridViewColumn();
        gc.Header = tmp.ToShortDateString();
        gc.Width = 100;
        this.myView.Columns.Add(gc);
        tmp = tmp.AddDays(1);
    }
}

【讨论】:

  • 如何将它绑定到我的 sqlite 数据上?
猜你喜欢
  • 1970-01-01
  • 2013-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-17
相关资源
最近更新 更多