1. devexpress grid: An error may occur when a parent-level grid is associated with a sub-grid: you cannot enable this constraint because not all values have corresponding parent values.
Solution:
Dsmain. relations. add ("Multicast information", dsmain. tables [0]. columns ["daypartid"], dsmain. tables [1]. columns ["daypartid"], false); // false indicates no parent-child constraints.
Dsmain is dataset, tables [0] is the data source of the parent table, and tables [1] is the data source of the slave table.
2. The sub-level grid can only be displayed through code:
# Region ### add sign on the left // set Private void setdetailcolumns (devexpress. xtragrid. gridcontrol gridctrl, devexpress. xtragrid. views. grid. gridview viewtemp, string colname, string caption, bool isvisible, bool isallowedit, string alignment, int width = 75, devexpress. utils. formattype = devexpress. utils. formattype. none, string formatstring = "", string controltype = "TXT") {viewtemp. columns [C Olname]. caption = Caption; viewtemp. columns [colname]. visible = isvisible; viewtemp. columns [colname]. optionscolumn. allowedit = isallowedit; viewtemp. columns [colname]. width = width; viewtemp. columns [colname]. displayformat. formattype = formattype; viewtemp. columns [colname]. displayformat. formatstring = formatstring; // column alignment if (alignment! = "") {Viewtemp. columns [colname]. appearancecell. textoptions. halignment = horzarignmentbystring (alignment);} viewtemp. columns [colname]. appearanceheader. textoptions. halignment = horzarignmentbystring ("center"); // refer to soet: soet_sys \ ControlSet \ xtragrid function: gv_createcolumn/devexpress. xtraeditors. repository. repositoryitemtextedit riteedit; // devexpress. xtraeditors. repository. repositoryitemcheckedit ricre Dit; // The column control initializes switch (controltype) {Case "TXT": // riteedit = new devexpress. xtraeditors. repository. repositoryitemtextedit (); // grdpublish. repositoryitems. addrange (New devexpress. xtraeditors. repository. repositoryitem [] {riteedit}); // viewtemp. columns [colname]. columnedit = riteedit; break; Case "Chk": devexpress. xtraeditors. repository. repositoryitemcheckedit ricredit; ricredit = new devexpress. XT Raeditors. repository. repositoryitemcheckedit (); ricredit. valuechecked = "1"; ricredit. valueunchecked = "0"; gridctrl. repositoryitems. addrange (New devexpress. xtraeditors. repository. repositoryitem [] {ricredit}); viewtemp. columns [colname]. columnedit = ricredit; break;} Private Static devexpress. utils. horzarignment horzarignmentbystring (string s) {If (S = "") return devexpress. utils. horzarignme NT. default; Return (devexpress. utils. horzarignment) enum. parse (typeof (devexpress. utils. horzarignment), S);} private void bandedgridviewappsmasterrowexpanded (Object sender, devexpress. xtragrid. views. grid. custommasterroweventargs e) {This. cursor = cursors. waitcursor; try {// bandedgridview1.clearselection (); detailview1 = NULL; detailview1 = This. bandedgridview1.getdetailview (E. rowhandle, E. relationi Ndex) as devexpress. xtragrid. views. grid. gridview; detailview1.selectionchanged + = new devexpress. data. selectionchangedeventhandler (detailviewappsselectionchanged); devexpress. xtragrid. views. bandedgrid. bandedgridview tmpview = (devexpress. xtragrid. views. bandedgrid. bandedgridview) detailview1; // only one band for (INT I = tmpview. bands. count; I> 1; I --) {tmpview. bands. removeat (1);} tmpview. optionsview. showban DS = false; setdetailcolumns (grdmain, detailview1, "daypartid", "Time period code", false, false, "near"); // hide the setdetailcolumns (grdmain, detailview1, "Item", "Serial Number", true, false, "near"); setdetailcolumns (grdmain, detailview1, "mediaid", "Media number", false, false, "Near"); // hide the setdetailcolumns (grdmain, detailview1, "medianame", "media name", true, false, "near", 300 ); // 300 setdetailcolumns (grdmain, detailview1, "starttim E "," Start time ", true, false," near "); setdetailcolumns (grdmain, detailview1," endtime "," end time ", true, false, "Near"); setdetailcolumns (grdmain, detailview1, "dayofweek", "broadcast Week", true, false, "near", 120); // 120 setdetailcolumns (grdmain, detailview1, "programname", "program name", true, false, "near", 400); // 400 setdetailcolumns (grdmain, detailview1, "position", "Time Slot", true, false, "near", 200); // 200 setdetailcol Umns (grdmain, detailview1, "rating", "rating", true, false, "near");} catch (exception ex) {xtramessagebox. show (ex. message, this. text);} finally {This. cursor = cursors. default; }}# endregion ### add # region ### select private void bandedgridview1_selectionchanged (Object sender, devexpress. data. selectionchangedeventargs e) {If (detailview1! = NULL & detailview1.getselectedrows (). length> 0) {detailview1.clearselection () ;}} private void detailview1_selectionchanged (Object sender, devexpress. data. selectionchangedeventargs e) {bandedgridview1.clearselection () ;}# endregion ### select only one grid at a time