H
H
Hirty2016-06-12 14:01:22
WPF
Hirty, 2016-06-12 14:01:22

DataGrid row number?

It is necessary to write down in a variable a line which I lead its number.
In this case, record only certain data.

DataRowView row = (DataRowView)gvData.SelectedItems[0];
                    
                    kj += row["ФИО"].ToString()+":";
                    kj += row["АДРЕС"].ToString()+"\n\r";

This is how you can write to the variable the string that I selected with the mouse.
But I need to manually enter the line number and write data from there.
Example
I have a table there
DI, full name, Address
1, Petrov O.S., Moscow
2, Sidirov A.T., Moscow
You need to enter the line number, example 2, and write down the data from there.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanostee, 2016-06-12
@Hirty

You can get a row by number using an indexer:

var rowIndex = 2;  // индекс первой строки равен 0
var row = (SomeType)DataGrid.Items[rowIndex];
row.SomeProperty = "...";

#
#algooptimize #bottize, 2016-06-12
@user004

there are other properties with selected

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question