New Posts New Posts RSS Feed: Bind to existing grid column?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Bind to existing grid column?

 Post Reply Post Reply
Author
Matthew View Drop Down
Newbie
Newbie


Joined: 31-Jul-2007
Posts: 14
Post Options Post Options   Quote Matthew Quote  Post ReplyReply Direct Link To This Post Topic: Bind to existing grid column?
    Posted: 15-Nov-2007 at 4:47pm
I have a Winforms DataGridView on a form to which I have added a few columns.  These columns inherit from DataGridViewTextBoxColumn.  Is there a way to have the Devforce grid binding manager use the existing columns instead of creating its own new columns?

I assumed that was why I would pass in the "typeof(TypeOfGridColumnHere)" when adding a descriptor, but in the end a standard winform textboxcolumn is added.

Thank you,
Matthew
Back to Top
jasonk View Drop Down
IdeaBlade
IdeaBlade


Joined: 14-Aug-2007
Posts: 3
Post Options Post Options   Quote jasonk Quote  Post ReplyReply Direct Link To This Post Posted: 19-Nov-2007 at 9:32am

You should be able to programmatically bind an existing column that has the same binding property path.  See below sample.

private void AddColumn(string pPropertyPath, string text) {

      ViewDescriptor vd = new ViewDescriptor(typeof(Customer), pPropertyPath);

      DataGridViewBindingDescriptor dgvbd = dataGridViewBindingManager1.Descriptors.Add(vd);

      dgvbd.Column.HeaderText = text;

    }

However, if the column is not bound or it is bound to a different property path, the “dataGridViewBindingManager1.Descriptors.Add” call will add a new column instead.

If there is another column that is also bound to the same property path and it has a valid ViewDescriptor, DF will also add a new column and ViewDescriptor.

 

Jason

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down