簡體   English   中英

如何從WPF中的C#獲取XAML中的DevExpress GridControl的內容

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

我需要訪問FieldName =“ Selected”為true的所有行。 之后,我需要檢索對應的FieldName =“ MyName”的所有值。 任何幫助表示贊賞。 我是所有這些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

    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#

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
    }
}

您也可以使用鏈接(到對象)發出請求

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM