c# - Timer does not start with opening a file with openFiledialog -
i want open excel file using openfiledialog() , show in datagridview want start timer when press open in openfiledialog
timer start when file loaded in datagridview;
edit:
@paulf right, no need wndproc
try this,
if(openfiledialog1.showdialog() == dialogresult.ok) { if (!string.isnullorempty(openfiledialog1.filename)) { timer1.start(); } }
you can capture openfiledialog
window wndproc
, here example,
bool isopenfiledialog = false; // global variable check if openfile opened private void button1_click_1(object sender, eventargs e) { isopenfiledialog = true; // button opens openfile dialog on click event openfiledialog1.showdialog(); // show it, waits until dialog closed isopenfiledialog = false; // after closed set false } private void timer1_tick(object sender, eventargs e) { textbox1.text += "ticking! \n"; // added textbox show ticking } protected override void wndproc(ref message m) { base.wndproc(ref m); if (m.msg == 289) // check message loop { if (!timer1.enabled && isopenfiledialog) { // if timer not running , button clicked open openfiledialog timer1.start(); // start timer } } }
Comments
Post a Comment