exception
-
HI i use three panel and each panel there are two or three buttons. each buton has MouseEnter and MouseLeave events.They are working fine But whenever i go throght 2nd panel by next button.there are two button one for Browse a file another for Browse a folder whaenever i click on Browse a folder button ,dialogbox appear and work fine But when i click on Browse for file button if appear over the form and also covered the button and dispaly exception at MouseEnter event . and whenever i comment the MouseEnter event line it dispaly error in Mouse leave event. and when i comment this line also it dispaly same exception at another control Mouse event plz help parshant
-
HI i use three panel and each panel there are two or three buttons. each buton has MouseEnter and MouseLeave events.They are working fine But whenever i go throght 2nd panel by next button.there are two button one for Browse a file another for Browse a folder whaenever i click on Browse a folder button ,dialogbox appear and work fine But when i click on Browse for file button if appear over the form and also covered the button and dispaly exception at MouseEnter event . and whenever i comment the MouseEnter event line it dispaly error in Mouse leave event. and when i comment this line also it dispaly same exception at another control Mouse event plz help parshant
Telling what exception you are getting is generally more helpful than
Parshant Verma wrote:
dispaly exception at MouseEnter
only two letters away from being an asset
-
HI i use three panel and each panel there are two or three buttons. each buton has MouseEnter and MouseLeave events.They are working fine But whenever i go throght 2nd panel by next button.there are two button one for Browse a file another for Browse a folder whaenever i click on Browse a folder button ,dialogbox appear and work fine But when i click on Browse for file button if appear over the form and also covered the button and dispaly exception at MouseEnter event . and whenever i comment the MouseEnter event line it dispaly error in Mouse leave event. and when i comment this line also it dispaly same exception at another control Mouse event plz help parshant
Parshant Verma wrote:
But when i click on Browse for file button if appear over the form and also covered the button and dispaly exception at MouseEnter event .
I don't understand what you mean by that sentence. What is appearing over the form?
--- b { font-weight: normal; }
-
Telling what exception you are getting is generally more helpful than
Parshant Verma wrote:
dispaly exception at MouseEnter
only two letters away from being an asset
it display exceptio: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in system.drawing.dll Additional information: png1\001.png and also open a Disassmebly and point to 00000056 mov ecx,esi
-
Parshant Verma wrote:
But when i click on Browse for file button if appear over the form and also covered the button and dispaly exception at MouseEnter event .
I don't understand what you mean by that sentence. What is appearing over the form?
--- b { font-weight: normal; }
my mean it this whenever i click on file button OpenFileDialog open and covered the file button Might be it relate to exception that why i told this point
-
it display exceptio: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in system.drawing.dll Additional information: png1\001.png and also open a Disassmebly and point to 00000056 mov ecx,esi
and you really don't understand why you are getting this exception?:rolleyes::wtf::sigh:
only two letters away from being an asset
-
and you really don't understand why you are getting this exception?:rolleyes::wtf::sigh:
only two letters away from being an asset
Exception says file not found i am getting but the same code working with another button Folder browse.
-
my mean it this whenever i click on file button OpenFileDialog open and covered the file button Might be it relate to exception that why i told this point
-
I see. What is the exception that you get, and what does the code look like?
--- b { font-weight: normal; }
exception i am getting file not found but before click on the file button everything going perfect and the same evevt is fine working private void btn_select_file_MouseEnter(object sender, System.EventArgs e) { try { file.Image=System.Drawing.Image.FromFile(@"png1\002.png"); } catch (System.Exception e1) { MessageBox.Show(e1.Message.ToString()); } } private void btn_select_file_MouseLeave(object sender, System.EventArgs e) { try { btn_select_file.BackgroundImage=System.Drawing.Image.FromFile(@"png1\001.png"); } catch (System.Exception e2) { MessageBox.Show(e2.Message.ToString()); } } private void btn_select_file_Click(object sender, System.EventArgs e) { if(openFileDialog.ShowDialog()==DialogResult.OK) { btn_select_file.DialogResult=DialogResult.OK; btn_select_file.BackgroundImage=System.Drawing.Image.FromFile(@"png1\002.png"); txt_select_file.Text=openFileDialog.FileName.ToString(); SelectButton=1; btn_select_folder.Enabled=false; } }
-
exception i am getting file not found but before click on the file button everything going perfect and the same evevt is fine working private void btn_select_file_MouseEnter(object sender, System.EventArgs e) { try { file.Image=System.Drawing.Image.FromFile(@"png1\002.png"); } catch (System.Exception e1) { MessageBox.Show(e1.Message.ToString()); } } private void btn_select_file_MouseLeave(object sender, System.EventArgs e) { try { btn_select_file.BackgroundImage=System.Drawing.Image.FromFile(@"png1\001.png"); } catch (System.Exception e2) { MessageBox.Show(e2.Message.ToString()); } } private void btn_select_file_Click(object sender, System.EventArgs e) { if(openFileDialog.ShowDialog()==DialogResult.OK) { btn_select_file.DialogResult=DialogResult.OK; btn_select_file.BackgroundImage=System.Drawing.Image.FromFile(@"png1\002.png"); txt_select_file.Text=openFileDialog.FileName.ToString(); SelectButton=1; btn_select_folder.Enabled=false; } }
This last information that you provided suddenly makes the error very obvious. It has nothing at all to do with event handling. You are opening files using a relative path, that means that you are using the current working directory as a starting point. The file selector dialog also uses the current working directory, and changes it as you navigate through the folders. That means that your code is trying to open the image files from a different starting point, where the images doesn't exist. The quick solution would be to store the value of the current directory when starting the application, so that you could use that value for locating the images. But I don't understand why you create a new
Image
object from a file every time the mouse pointer enters or leaves the control. You'd be better off by loading the images at startup, so that you can use the sameImage
objects over and over.--- b { font-weight: normal; }