Search code examples
c#winformsdevexpressdatasourcextragrid

About devexpress xtragrid's datasource property


I'm using DevExpress's xtragrid control. In my application I'm setting the datasource property of gridcontrol at runtime but it not show my updated table value when my form displays.

How to resolve this problem?

I have one main form & other are child ones. I placed my gridview on my child form & which is actually a user control. And in that user control I have my gridview & one bar button item & when I click on button then one form get opened & I fill that form & this information I'm showing on my grid view, it works fine.

And my main form also has one button. When I click on that button then also the same form gets opened & when I fill data in that form then I want to show that information in my grid view which is on the user control for that I used the datasource property as well as refreshdatasource() method of grid control but it not showing the inserted value in my grid view. I created my gridview's columns at run time. What should I do now?

I used event handling for this. My events are declared on the detail form which is opened when i click on bar button item. The event declaration is as follows-

public event DataAddedEventHandler DataAdded;
public delegate void DataAddedEventHandler();

below is event handling function & event registration which is on the usercontrol- ofrmAddContact is the object of my details form.

ofrmAddContact.DataAdded += new frmAddContact.DataAddedEventHandler(AddRow);

private void AddRow()
{
xgBase.DataSource = dbContact.selectAllContacts();
xgBase.RefreshDataSource();
}  

i register event when i click on the bar button item of the user control as well as when i click on the main form button

thanks...


Solution

  • i solved my problem it is happened because of my object of user control