我是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>
在这里,现在我想得到选定的公司身份?帮助感激!谢谢!
发布于 2013-05-13 07:08:06
代码隐藏方式
您可以使用以下代码片段通过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方式
可以在FocusedRow中定义ViewModel属性,并将其绑定到TreeListView.FocusedRow属性。
https://stackoverflow.com/questions/16515472
复制相似问题