简体   繁体   English

如何从WPF中的C#获取XAML中的DevExpress GridControl的内容

[英]How to get the content of a DevExpress GridControl in XAML from C# in WPF

I need to access all the rows in which the FieldName="Selected" is true . 我需要访问FieldName =“ Selected”为true的所有行。 I need to retrive all the values for the corresponding FieldName="MyName" afterward. 之后,我需要检索对应的FieldName =“ MyName”的所有值。 Any help is appreciated. 任何帮助表示赞赏。 I am new to all this MVVM, WPF, XAML, DataBinding , Dependency Objects , Dependency Propety Stuff. 我是所有这些MVVM,WPF,XAML,DataBinding,依赖对象,依赖属性的新手。

   <dxg:GridControl DefaultSorting="Selected" Grid.ColumnSpan="3" AutoPopulateColumns="True"      HorizontalAlignment="Stretch" Name="gridControl1" VerticalAlignment="Stretch" Margin="2,2,2,2" ItemsSource="{Binding Dependencies}">
 <dxg:GridControl.Columns>
 <dxg:GridColumn FieldName="Selected" Header="Mapped" SortOrder="Descending" Width="80"/>
 <dxg:GridColumn FieldName="MyName" Header="Name" ReadOnly="True"/>
 <dxg:GridColumn FieldName="LastName" ReadOnly="True" Width="80"/>
 <dxg:GridColumn FieldName="FileLastModificationDate" ReadOnly="True" Header="Dependency Last    Modified" AllowEditing="False"/>
 <dxg:GridColumn FieldName="RecordLastModified" ReadOnly="True" Header="Record Last Modified" AllowEditing="False"/>
 <dxg:GridColumn FieldName="Description"/>
 </dxg:GridControl.Columns>

VB.NET VB.NET

    Dim Count As Integer
    Dim Coll As New Collection
    Dim _YourBindedClass As YourBindedClass

    Count = GridControl.VisibleRowCount

    For i = 0 To Count - 1
        _YourBindedClass = GridControl.GetRow(i)
        If _YourBindedClass.Selected = True Then
            Coll.Add(_YourBindedClass.MyName)  'Get the "MyName" values here and add to collection
        End If
    Next

C# C#

int Count = 0;
Collection Coll = new Collection();
YourBindedClass _YourBindedClass = default(YourBindedClass);

Count = GridControl.VisibleRowCount;

for (i = 0; i <= Count - 1; i++) {

    _YourBindedClass = GridControl.GetRow(i);
    if (_YourBindedClass.Selected == true) {
        Coll.Add(_YourBindedClass.MyName);
        //Get the "MyName" values here and add to collection
    }
}

Also you can make a request using the Link (to objects) 您也可以使用链接(到对象)发出请求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM