0

Devexpress コントロールは初めてです。TreeListエンティティを使用してバインドするフォームにコントロールを追加しました。選択した列の値、つまりIDを取得したい

.Xaml ファイル:

<dxg:TreeListControl Name="treeListContacts" ItemsSource="{Binding Data, Source={StaticResource EntityServerModeDataSource2}}" AutoPopulateColumns="True" HorizontalAlignment="Left" Margin="10,19,0,0" VerticalAlignment="Top" Height="317" Width="180" FocusableChanged="treeListContacts_FocusableChanged">
            <dxg:TreeListControl.Columns>
                <dxg:TreeListColumn FieldName="Company_ID" ReadOnly="True" Width="30" Visible="False"/>
                <dxg:TreeListColumn FieldName="CompanyName" ReadOnly="True"/>
            </dxg:TreeListControl.Columns>
            <dxg:TreeListControl.View>
                <dxg:TreeListView ShowTotalSummary="True"/>
            </dxg:TreeListControl.View>
        </dxg:TreeListControl>

ここで、選択した会社IDを取得したいですか? 助けて感謝!ありがとう!

4

1 に答える 1

1

コード ビハインドの方法:次のコード スニペットを使用して、 TreeListView.GetNodeValue
メソッドを 介して、フォーカスされた行に含まれる指定されたセルの値を取得できます。

詳細については、セル値の取得と設定を参照してください。

<dxg:TreeListControl ItemsSource="{Binding Data, Source={StaticResource EntityServerModeDataSource2}}" AutoPopulateColumns="True" HorizontalAlignment="Left" Margin="10,19,0,0" VerticalAlignment="Top" Height="317" Width="180" FocusableChanged="treeListContacts_FocusableChanged">
    <dxg:TreeListControl.Columns>
        <dxg:TreeListColumn FieldName="Company_ID" ReadOnly="True" Width="30" Visible="False"/>
        <dxg:TreeListColumn FieldName="CompanyName" ReadOnly="True"/>
    </dxg:TreeListControl.Columns>
    <dxg:TreeListControl.View>
        <dxg:TreeListView ShowTotalSummary="True" x:Name="treeListView"/>
    </dxg:TreeListControl.View>
</dxg:TreeListControl>


//...
object id = treelistView.GetNodeValue(treelistView.FocusedNode, "Company_ID");

MVVM の方法: ViewModel で FocusedRow プロパティを定義し、それをTreeListView.FocusedRow
プロパティにバインドできます。

于 2013-05-13T07:08:06.617 に答える