How can I get a value of a property from an anonymous type?

后端 未结 12 1280
南旧
南旧 2020-12-24 08:34

I have a datagrid populated by a Linq query. When the focused row in the datagrid changes I need to set a variable equal to one of the properties in that object.

I t

12条回答
  •  情深已故
    2020-12-24 09:27

    DevExpress's xtraGridView has a method like this GetRowCellDisplayText(int rowHandle, GridColumn column). With this method, the following code returns the id from the anonymous type.

    var _selectedId = view.GetRowCellDisplayText(rowHandle, "Id");
    

    Though this does not provide an answer to the question "How can I get access to the anonymous object's property?", it still attempts to solve the root cause of the problem.

    I tried this with devXpress version 11.1 and I can see that the question was first asked almost 2.5 years ago. Possibly the author of the question might have got an workaround or found the solution himself. Yet, I am still answering so that it might help someone.

提交回复
热议问题