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


C# DataGrid.GetCellValue方法代码示例

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


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

示例1: Array2DTransposed

        public void Array2DTransposed()
        {
            var array = new[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
            var dataGrid = new DataGrid();
            dataGrid.SetValue(ItemsSource.Array2DTransposedProperty, array);
            dataGrid.Initialize();
            Assert.IsInstanceOf<Array2DView>(dataGrid.ItemsSource);
            Assert.AreEqual(3, dataGrid.Columns.Count);
            Assert.AreEqual(2, dataGrid.Items.Count);

            Assert.AreEqual(1, dataGrid.GetCellValue(0, 0));
            Assert.AreEqual(3, dataGrid.GetCellValue(0, 1));
            Assert.AreEqual(5, dataGrid.GetCellValue(0, 2));

            Assert.AreEqual(2, dataGrid.GetCellValue(1, 0));
            Assert.AreEqual(4, dataGrid.GetCellValue(1, 1));
            Assert.AreEqual(6, dataGrid.GetCellValue(1, 2));
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.DataGrid2D,代码行数:18,代码来源:ItemsSourceTests.cs

示例2: RowsSource

        public void RowsSource()
        {
            var ints = new ObservableCollection<ObservableCollection<int>>
                           {
                               new ObservableCollection<int>(new[] { 1, 2 }),
                               new ObservableCollection<int>(new[] { 3, 4 }),
                               new ObservableCollection<int>(new[] { 5, 6 })
                           };
            var dataGrid = new DataGrid();
            dataGrid.SetValue(ItemsSource.RowsSourceProperty, ints);
            dataGrid.Initialize();
            Assert.IsInstanceOf<Lists2DView>(dataGrid.ItemsSource);

            Assert.AreEqual(1, dataGrid.GetCellValue(0, 0));
            Assert.AreEqual(2, dataGrid.GetCellValue(0, 1));

            Assert.AreEqual(3, dataGrid.GetCellValue(1, 0));
            Assert.AreEqual(4, dataGrid.GetCellValue(1, 1));

            Assert.AreEqual(5, dataGrid.GetCellValue(2, 0));
            Assert.AreEqual(6, dataGrid.GetCellValue(2, 1));
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.DataGrid2D,代码行数:22,代码来源:ItemsSourceTests.cs

示例3: TransposedSource

        public void TransposedSource()
        {
            var persons = new ObservableCollection<Person> { new Person { FirstName = "Johan", LastName = "Larsson" } };
            var dataGrid = new DataGrid();
            dataGrid.SetValue(ItemsSource.TransposedSourceProperty, persons);
            dataGrid.Initialize();

            var itemsSource = dataGrid.ItemsSource;
            Assert.IsInstanceOf<TransposedItemsSource>(itemsSource);
            Assert.AreEqual(2, dataGrid.Columns.Count);
            Assert.AreEqual(2, dataGrid.Items.Count);

            Assert.AreEqual("FirstName", dataGrid.GetCellValue(0, 0));
            Assert.AreEqual("Johan", dataGrid.GetCellValue(0, 1));

            Assert.AreEqual("LastName", dataGrid.GetCellValue(1, 0));
            Assert.AreEqual("Larsson", dataGrid.GetCellValue(1, 1));

            persons.Add(new Person { FirstName = "Erik", LastName = "Svensson" });
            Assert.AreNotSame(itemsSource, dataGrid.ItemsSource);
            Assert.AreEqual(3, dataGrid.Columns.Count);
            Assert.AreEqual(2, dataGrid.Items.Count);

            /*
            Assert.AreEqual("FirstName", dataGrid.GetCellValue(0, 0));
            Assert.AreEqual("Johan", dataGrid.GetCellValue(0, 1));
            Assert.AreEqual("Erik", dataGrid.GetCellValue(0, 2));

            Assert.AreEqual("LastName", dataGrid.GetCellValue(1, 0));
            Assert.AreEqual("Larsson", dataGrid.GetCellValue(1, 1));
            Assert.AreEqual("Svensson", dataGrid.GetCellValue(1, 2));
            */
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.DataGrid2D,代码行数:33,代码来源:ItemsSourceTests.cs


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