In this case, you often need to load different headers in a form based on different data sources. xtragrid can be easily implemented.
1. Use xtragrid to create two header files and store them as XML files.
2. Make corresponding calls in the code
Texture first:
Post Code
Private void simplebutton#click (Object sender, eventargs E)
{
Gridview1.restorelayoutfromxml (
Path. Combine (application. startuppath, "detaila. xml"), devexpress. utils. optionslayoutbase. fulllayout );
// Gridview1.datasource = dataset1
}
Private void simplebutton2_click (Object sender, eventargs E)
{
Gridview1.restorelayoutfromxml (
Path. Combine (application. startuppath, "detailb. xml"), devexpress. utils. optionslayoutbase. fulllayout );
// Gridview1.datasource = dataset2
}
The code is very simple, but I made a mistake and didn't use the devexpress. utils. optionslayoutbase. fulllayout option, leading to abnormal loading of dead and dead column headers.
Of course, we can also use the event when the form is closed to save the required table attributes [method: savelayouttoxml ()], and then use [restorelayoutfromxml ()] method to load user configurations