1
votes

I have a DataGrid on a WPF-form.

Now I want to set a cell value for a certain cell (correct the format of the date is this case). The datagrid is connected to a ItemsSource.

I found several ways to get the Cel Value like: - GetCell the setting the cell.Content.Text (after cast to TextBlock). - or from the ItemsSource: data.Rows[j].ItemArray.GetValue(i).ToString();

Now I want to set the text content of the the a cell ( i have the datagrid, column end row/item number).

How to set the value? It must appear on the datagrid direclty.

thanks, Leo!

1

1 Answers

1
votes

If you used a binding on the cell to populate it with data, you could use a custom converter to automatically format it.

Are you accessing the datagrid from the codebehind? If so, it is going to get really messy. I would highly suggest looking into migrating to MVVM pattern to simplify it.