datagridcell

WPF DataGrid: How to Determine the Current Row Index?

送分小仙女□ 提交于 2019-11-29 06:14:49
问题 I am trying to implement a very simple spreadsheet functionality based on a DataGrid. The user clicks on a cell The user types a value and presses return The current row is scanned and any cell formula that depends on the clicked cell is updated. This seems to be the best event handler for my requirements: private void my_dataGrid_CurrentCellChanged(object sender, EventArgs e) Question: How do I detect the row index of the current row? 回答1: Try this (assuming the name of your grid is "my

How to make WPF DataGridCell ReadOnly?

≯℡__Kan透↙ 提交于 2019-11-28 23:38:19
I understand you can make the whole DataGrid or a whole column readyonly (IsReadOnly = true). However, at cell level this property is ready only. But I do need this level of granularity. There is blog about adding IsReadOnly to a row by changing the source code in old days when DataGrid was public domain, but now I don't have source code for DataGrid. What's workaround? Making cell disabled (IsEnabled=false) almost meets my need. But the problem is that you can't even click the disabled cell to select the row (I have full row selection mode). EDIT: Since nobody has responded to this question,

How to make WPF DataGridCell ReadOnly?

主宰稳场 提交于 2019-11-27 21:22:17
问题 I understand you can make the whole DataGrid or a whole column readyonly (IsReadOnly = true). However, at cell level this property is ready only. But I do need this level of granularity. There is blog about adding IsReadOnly to a row by changing the source code in old days when DataGrid was public domain, but now I don't have source code for DataGrid. What's workaround? Making cell disabled (IsEnabled=false) almost meets my need. But the problem is that you can't even click the disabled cell

Binding a cell object's property to a DataGridCell in WPF DataGrid

此生再无相见时 提交于 2019-11-26 21:56:49
问题 Using the WPF DataGrid I have the need to change various display and related properties of a DataGridCell - such as Foreground, FontStyle, IsEnabled and so on - based on the relevant value of the cell object property. Now this is easy to do in code, for example (using an Observable Collection of ObservableDictionaries): var b = new Binding("IsLocked") { Source = row[column], Converter = new BoolToFontStyleConverter() }; cell.SetBinding(Control.FontStyleProperty, b); and works fine, however I