c# - If statment on button content . WPF -
i have listview 1 button( default content == "add") , 1 textbox. on list view double click event buttons.content=="edit" , text box fills information listview.
this if statment not work correctly
if (btnaddfloor.content == "add") { hprodatacontext db = new hprodatacontext(); floor f = new floor { floorname = txtfloorname.text }; db.floors.insertonsubmit(f); db.submitchanges(); refreshlistviewfloor(); } else { int currentid = convert.toint32(listviewfloors.selectedvalue); hprodatacontext db = new hprodatacontext(); floor f = db.floors.single(p => p.id == currentid); f.floorname = txtfloorname.text; db.submitchanges(); refreshlistviewfloor(); txtfloorname.text = null; refreshlistviewroom(); }
and on btnaddfloor.content == "add" green underline can me?
xaml
<groupbox header="floors" height="287" horizontalalignment="left" margin="12,32,0,0" name="groupboxfloors" verticalalignment="top" width="342"> <grid> <button content="add" height="23" horizontalalignment="left" margin="169,37,0,0" name="btnaddfloor" verticalalignment="top" width="75" click="btnaddfloor_click" /> <listview height="192" horizontalalignment="left" margin="6,66,0,0" name="listviewfloors" verticalalignment="top" width="318" itemssource="{binding floorcollection}" selectedvaluepath="id" mousedoubleclick="listviewfloors_mousedoubleclick"> <listview.view > <gridview> <gridviewcolumn header="id" width="60" displaymemberbinding="{binding id}"/> <gridviewcolumn header="floorname" width="200" displaymemberbinding="{binding floorname}"/> </gridview> </listview.view> </listview> <textbox height="23" horizontalalignment="left" margin="6,37,0,0" name="txtfloorname" verticalalignment="top" width="157" textchanged="txtfloorname_textchanged" /> <button content="remove" height="23" horizontalalignment="left" margin="249,37,0,0" name="btnremovefloor" verticalalignment="top" width="75" click="btnremovefloor_click" /> <label content="floor name" height="28" horizontalalignment="left" margin="6,6,0,0" name="label1" verticalalignment="top" /> </grid> </groupbox>
button.content of type object, using "==" operator compare pointers. want is:
btnaddfloor.content.tostring() == "add"
Comments
Post a Comment