开发者

Problem with setting focus on WPF DataGridTextColumn

I have WPF DataGr开发者_如何学JAVAid like below:

<DataGrid x:Name="MasterMemlinesDataGrid"
          ItemSources= "{Binding MyItems}"
          SelectedItem= "{Binding SelectedItem}">
  <DataGrid.Columns>
     <DataGridTextColumn Width="110" x:Name="ItemCodeTextColumn"
         Binding="{Binding ItemCode}" />
     <DataGridTextColumn Width="110" x:Name="ItemDescTextColumn"
         IsReadOnly="True" Binding="{Binding ItemDescription}" />
     <DataGridTextColumn Width="110" x:Name="ItemManiDescTextColumn"
         Binding="{Binding ItemMainDescription}" />
  </DataGrid.Columns>
</DataGrid>

Also I have a button which open a view and displays a list of item. After user selects a item, I will update the "ItemCodeTextColumn" and "ItemDescTextColumn" to display the select item, then set focus to the "ItemManiDescTextColumn" cell. Can anyone let me know how I can set the focus to the "ItemManiDescTextColumn" cell?

Thank you


Assuming you have a row & column index for this cell, Artur has some datagrid extension methods that get a cell from a row & column index. Once you have the cell you just call the cells focus method.

http://techiethings.blogspot.com/2010/05/get-wpf-datagrid-row-and-cell.html

If you don't know the column index but do know the column, you could find it's index using DataGrid.Columns.IndexOf( ItemManiDescTextColumn )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜