c# - Arranging in order with reference to a column -
i have mysql database table ( using entity framework ) :
here codes use retrieve , populate them on wpf : crud class file :
//get records based on activityid , taskid. public ilist<model.questionhint> getrecords(int listtask, int listactivity) { ilist<model.questionhint> lstrecords = context.questionhints.tolist(); return lstrecords.where(a => a.taskid == listtask && a.activityid == listactivity).tolist(); }
code behind :
public mainwindow2() { initializecomponent(); populatequestion(1, 5); } private void populatequestion(int activityid, int taskid) { ilist<model.questionhint> lstquestionhints = qh.getrecords(taskid, activityid); foreach(model.questionhint qhm in lstquestionhints) { textblock tb = new textblock(); tb.text = qhm.questioncontent; tb.fontweight = fontweights.bold; tb.fontsize = 24; wrappaneltest.children.add(lbl); if (qhm.option1.trim().length > 0 && qhm.option2.trim().length > 0) { combobox cb = new combobox(); cb.items.add(qhm.option1); cb.items.add(qhm.option2); cb.width = 200; wrappaneltest.children.add(cb); } } }
how appear on program :
as can see , questions compounded , want separate them based on questionno in above database table ( example few records same questionno should compound together.)but got totally no idea how . want separate them :
i [combobox] have nap every afternoon.
the sun [combobox] not move round earth.
appreciate on , in advance.
try this
stackpanel sp=new stackpanel(); foreach(model.questionhint qhm in lstquestionhints) { stackpanel sp1=new stackpanel(){orientation=orientation.horizontal}; textblock tb = new textblock(); tb.text = qhm.questioncontent; tb.fontweight = fontweights.bold; tb.fontsize = 24; sp1.children.add(lbl); if (qhm.option1.trim().length > 0 && qhm.option2.trim().length > 0) { combobox cb = new combobox(); cb.items.add(qhm.option1); cb.items.add(qhm.option2); cb.width = 200; sp1.children.add(cb); } sp.children.add(sp1); } wrappaneltest.children.add(sp);
Comments
Post a Comment