2

Lets say that I have the two following classes

public class OtherClass
{
    public string OtherName{ get; set; }
}

public class MyClass
{
    public string TheName { get; set; }
    public int TheAge { get; set; }
}

lets say that I bound the XtraGrid to the Object datasource (MyClass )

Now, My scenario is that I want to populate the first column (TheName) when I click the Editor button with OtherName values came from list of OtherClass object (List<OtherClass>)

then finally transfer the whole Row back to MyClass object

is that possible?

Rami Alshareef
  • 7,015
  • 12
  • 47
  • 75
  • You might want to word it a little better, What is the "Editor button" are you talking about having a LookupEdit with the source being a List and when you select something from the LookupEdit you want that placed in "TheName" property of the current row? Happy to help but just need to understand it better. – AussieALF Nov 29 '11 at 03:23

1 Answers1

0

maybe like this:

        List<MyClass> mylist = new List<MyClass>();
        mylist.Add(new MyClass() { TheName = "Kirk", TheAge = 56 });
        mylist.Add(new MyClass() { TheName = "Spock", TheAge = 403 });
        mygrid.DataSource = mylist;
        mygrid.MainView.PopulateColumns();

        List<OtherClass> all_names = new List<OtherClass>();

add existing names here :

        foreach (var item in mylist)
            all_names.Add( new OtherClass() { OtherName = item.TheName } );

continue with additional names:

        all_names.Add(new OtherClass() { OtherName = "Watson" });
        all_names.Add(new OtherClass() { OtherName = "Sherlock" });

create repositoryItemLookUpEdit1 via designer

        repositoryItemLookUpEdit1.DataSource = all_names;
        repositoryItemLookUpEdit1.DisplayMember = "OtherName";
        repositoryItemLookUpEdit1.ValueMember = "OtherName";
        ((DevExpress.XtraGrid.Views.Base.ColumnView)mygrid.MainView).Columns[0].ColumnEdit = repositoryItemLookUpEdit1;

and your data should be fine

ralf.w.
  • 1,676
  • 1
  • 24
  • 34