Getting values ​​from gridView cell C #

I want to get data from a cell from a selected row in a gridView and bring it into a different form inside a text element that will then edit the row of the selected cell, the problem is that when using

var cacca = this.gridView.getFocusedRow() as PartnersMissing;
MessageBox.show(cacca.toString()) 

messageBox writes Test01.parnersMissingwhere Test01 is the name of the project, and I really don't know why it PartnersMissingis. What is wrong with this code? The datagrid data has data from the sql database and is created using DevExpress. Please do not pay attention to variable names, if you know Italian, I was in a hurry: D

+4
source share
2 answers

, GridView GetFocusedRow. , .

List<PartnersMissing>, GetFocusedRow. , .

: PartnersMissing ABC, , :

var cacca = this.gridView.getFocusedRow() as PartnersMissing;
MessageBox.show(cacca.ABC) 

ToString() , . , .

, " PartnersMissing" GetFocusedRowCellValue (String).

+1

, , cacca.toString() , object.ToString.

- ,

class PartnersMissing { 
    public string Name { get; set; }
    public override string ToString(){
         return Name;
    }
}

:

MessageBox.Show(cacca.Name);

gridView:

string name = gridView.GetFocusedRowCellValue("Name");
+1

Source: https://habr.com/ru/post/1672797/


All Articles