Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
305
please i have 2 questions
posted

1) There are any way to show an object inside another object into a grid view?

ej: public class MyObject1

    {

        public string object1{ get; set; }

        public MyObject2 obj2{ get; set; }

}

public class MyObject2

    {

        public string name{ get; set; }

        public string LastName{ get; set; }

}

row : object1 | name | LastName

 

2) question 

if i bind a win grid with and object, Whenever i change anything in the row ,the object changes , which is fine.Now, if i do not want to have that change saved i press "close",but the object itself gets changed.

i'm wondering whether i can follow the about procedure without resulting in the object being changed.

 

THANKS 

Parents
  • 469350
    Verified Answer
    Offline posted

    1) Not directly. You would have to add a couple of unbound column to the root band in the grid and then use the InitializeRow event to populate the unbound columns from the object properties. If these are to be updateable, then you would also have to reverse this process - probably in the BeforeRowUpdate event.

    2) The grid is always going to write changes to it's DataSource. There's no way around that. If you bind the grid to a DataSet or DataTable, then the DataSet or DataTable have built-in functionality to track changes and gives you the ability to undo them. So this is something the data source needs to handle, it cannot be handled by the grid.

    Perhaps what you could do is bind the grid to a copy or clone of your objects so the real ones will not be affected.

Reply Children
No Data