I can show data in GridView, now I need find a row with user input in DataGridView so the cursor moves to this row, get this row and update the field (I want updated fields in a textbox on the form , after update), show updated row in datagridview and cursor move to next row automaticaly
Can someone help me?
let's say you'r binded data artifact (class is MyData
)
public class MyData
{
public string Name {get;set;}
public string Address {get;set}
}
so yuo have somewhere a collection of of MyData
like List<MyData>
List<MyData> myDataList = new List<MyData>();
and do somewhere in the code, I presume, something like this:
dataGrid.DataSource=myDataList
Now, yo want to find some row on DataGrid
, but you really want is to find a data . So, make a query over the myDataList
to find MyData
object of interest, let's say like this
var foundMyData = from data in myDataList where (. condition..) select data;
We found the data we interested in, so no let-\\'s make it selected on UI
. So find the index of the foundMyData
in the list and select corresponding row on the grid.
If you use Sorting
, or View
so the data visible on the screen can be filtered or sorted, you need to consider that "transformations" too, naturally.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.