c# - Create a status bar? -
i moving rows table 1 server another using c# script. please don't tell me use ssis components that. looping incoming dataset using loop , want see current iteration, ie loop index in gui box. can use messagebox.show("text"), need press ok/cancel allow code continue. so, thought of using status bar instead. tried an example got online
the line this.controls.add(mainstatusbar); in example (below) causes error -
csproj.scriptmain' not contain definition 'controls' , no extension method 'controls' accepting first argument of type '.csproj.scriptmain' found (are missing using directive or assembly reference?)
this happens despite adding reference - system.windows.forms.dll , doing save (ie ctrl+shift+s). script has import using system.windows.forms; already.
why getting error , how fix ?
code -
protected statusbar mainstatusbar = new statusbar(); protected statusbarpanel statuspanel = new statusbarpanel(); protected statusbarpanel datetimepanel = new statusbarpanel(); private void createstatusbar() { // set first panel properties , add statusbar statuspanel.borderstyle = statusbarpanelborderstyle.sunken; statuspanel.text = "application started. no action yet."; statuspanel.tooltiptext = "last activity"; statuspanel.autosize = statusbarpanelautosize.spring; mainstatusbar.panels.add(statuspanel); // set second panel properties , add statusbar datetimepanel.borderstyle = statusbarpanelborderstyle.raised; datetimepanel.tooltiptext = "datetime: " + system.datetime.today.tostring(); datetimepanel.text = system.datetime.today.tolongdatestring(); datetimepanel.autosize = statusbarpanelautosize.contents; mainstatusbar.panels.add(datetimepanel); mainstatusbar.showpanels = true; // add statusbar form controls this.controls.add(mainstatusbar); } private void button1_click(object sender, eventargs e) { statuspanel.text = "button clicked."; } private void checkbox1_checkedchanged(object sender, eventargs e) { statuspanel.text = "checkbox checked."; } private void textbox1_textchanged(object sender, eventargs e) { statuspanel.text = "textbox edited."; }
the program doesn't know this supposed refer form in statement this.controls.add(mainstatusbar);
you have way percentage has suggested.
the proper way use :
for instance
public partial class someform : form { public someform() { initializecomponent(); } } partial class someform { private void initializecomponent() { this.mainstatusbar = new statusbar(); } } also, take @ article :
Comments
Post a Comment