Ticket T329537
Visible to All Users
Duplicate

How could I access the currently selected object in listview "DataView" DataAccessMode

created 9 years ago

How could I access the currently selected object in XAF listview. all our actions are no longer valid when I changed this option to 'DataView'. However, when I clicked on the default 'Show in a report' action, it worked.

I think there is a way to get at least the Oid of the currently selected object.

I need this to improve the performance of my application, because it is too slow. and I couldn't follow my past ticket about performance.

Comments (2)

    When I watched the currently selected object, I saw its Oid in the ToString function as appeared in the attachment, but I couldn't exactly find where it's stored.
    I need your help

      The object type is XpoDataViewRecord

      Answers approved by DevExpress Support

      created 9 years ago (modified 9 years ago)

      Hello Yaser.

      To get the real object, use the View.ObjectSpace.GetObject method. For example:

      C#
      void action_Execute(object sender, SimpleActionExecuteEventArgs e) { var currentObject = View.ObjectSpace.GetObject(View.CurrentObject); var currentObjectKey = View.ObjectSpace.GetKeyValue(View.CurrentObject); //or with multiple selected objects: foreach (var obj in e.SelectedObjects) { var selectedObject = View.ObjectSpace.GetObject(obj); //do something } }
      Visual Basic
      Private Sub action_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs) Dim currentObject = View.ObjectSpace.GetObject(View.CurrentObject) Dim currentObjectKey = View.ObjectSpace.GetKeyValue(View.CurrentObject) 'or with multiple selected objects: For Each obj In e.SelectedObjects Dim selectedObject = View.ObjectSpace.GetObject(obj) 'do something Next obj End Sub

      See also:
      Actions & DataViewMode: Converting eventArgs / SelectedObjects

        Comments (2)

          My question is straight forward, All I want to know, How to get the currently selected Object Oid without taking the value from the (Selected Item) ToString Function.
          could you provide me with some code. see the attached pic.
          How to get these values, I couldn't get them using GetObjectFunction

          DevExpress Support Team 9 years ago

            I believe your task is to get the selected object itself, not only its key. I have updated my answer with sample code for both tasks. Let me know if anything is still unclear.

            Other Answers

            created 9 years ago

            Thanks, exactly what i want

              Comments (1)
              DevExpress Support Team 9 years ago

                You're welcome.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.