0
votes

i have a ComponentOne FlexGrid bound to a bindingsource and the bindingsource is bound to a bindinglist collection.

The user clicks an insert button. I call AddNew() on the BindingSource. in the AddingNew() event, i want to initialize the properties in the bindingsource. usually if i want to access the data underlying the grid row i do this

MemberSkill skill = (MemberSkill)MemberSkillBS.Current

skill.SocSecNo = currentMember.SocSecNo;

but when i do this in the AddingNew() event, Current is still pointing to the row with the focus on the grid. how can i access the new item i added to the binding source and initialize it?

1
The new added row is not added to current BO until first post is not done, until first post this row can be undone. Post the data and after this you will get the row from BindingSource. - ctescu

1 Answers

2
votes

The new item becomes the current item after the AddNew has been called.

In your Insert button handler you do:

    private void buttonInsert_Click(object sender, EventArgs e)
    {
        MemberSkill newItem = MemberSkillBS.AddNew() as MemberSkill;
        if (newItem != null)
        {
            MemberSkillBS.Add(newItem);
        }
        ...
    }

and in your AddingNew handler you do:

    private void MemberSkillBS_AddingNew(object sender, AddingNewEventArgs e)
    {
         MemberSkill skill = new MemberSkill
        {
           SocSecNo = MemberSkillBS.Current.SocSecNo
        };
        e.NewObject = skill;
    }