|
Yes you would need PointToClient; you can verify the coordinates by looking at them,
e.g. with Console.WriteLine while running in debug mode. You can also get current
mouse position from Cursor.Position
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks for the pointers, I'll continue to poke at it with a large stick. Eventually it will cave.
|
|
|
|
|
hello ALL,
I have a doubt.
if i want to continue normally after catching the expecteed exception is it possible??
Ex:-
try
{
int intDivVal;
for (int i =o ;i<5;i++)
{
int Divval=10/i;
}
}
catch(dividebyzeroexception ex)
{
messagebox.show(ex.message.tostring());
}
i want to continue after showing the message.
Thanks in advance
Bharath.S Ron
|
|
|
|
|
yep your code there will carry right on.
If you continue you have to think about anything that might have broken during an exception though i.e. was something being set to a value or a stream being opened.
Carrying on can lead to losing data or more expcetions.
If you want to do something with the exception and then let the exception carry on then you can
catch(dividebyzeroexception ex)
{
messagebox.show(ex.message.tostring());
throw ex;
}
|
|
|
|
|
originSH wrote: catch(dividebyzeroexception ex)
{
messagebox.show(ex.message.tostring());
throw ex;
}
You actually want to just do a throw here rather than throw ex . The throw ex causes the original stack trace information to be lost while throw preserves it.
|
|
|
|
|
ahhh yeah "throw;" maps to rethrow doesn't it...
|
|
|
|
|
Yep. throw is rethrow in the IL.
|
|
|
|
|
hello
It will continue as you wrote it. Alternatively, you can use the finally statement to make sure some code is executed in all cases (try succeeded or catch executed)
Talal
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Yeah, I understand you want to continue your loop after the exception is thrown...
In your code the try & catch block contains the loop...
<br />
try<br />
{<br />
int intDivVal;<br />
for (int i =o ;i<5;i++)<br />
{<br />
int Divval=10/i;<br />
}<br />
}<br />
catch(dividebyzeroexception ex)<br />
{<br />
messagebox.show(ex.message.tostring());<br />
}<br />
However, the loop should contain a try & catch block in order to continue the loop
try<br />
{<br />
int intDivVal;<br />
for (int i =o ;i<5;i++)<br />
{<br />
try<br />
{<br />
int Divval=10/i;<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Oops, 10 / " + i + " failed!");<br />
}<br />
}<br />
}<br />
catch(dividebyzeroexception ex)<br />
{<br />
messagebox.show(ex.message.tostring());<br />
}
|
|
|
|
|
You should think about continuation that makes sense. You may return to an input for example, or substitute the illegal result with something that makes sense for you application. Just ignoring the exception is generally not a very good idea.
Rudolf Heijink
|
|
|
|
|
i have four fields in an exel file (EmpID, EmpName ,EmpSalary and DepartmentName) . I want to import these fields to a Datagrid view in my application and to database also. Pls help me with code of this application... I am using C# windows application .....
|
|
|
|
|
This[^] message may help... Anyway, removing a message and the reposting it certainly doesn't...
|
|
|
|
|
This is the third post of this request. It has been answered in both of the previous messages. You need to use the OLEDB provider. Select everything from the file, and load it into a data table. You can then set the datasource of your GridView to said DataTable. Oh yeah, READ THE FORUM rules.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
nish85 wrote: i have four fields in an exel file (EmpID, EmpName ,EmpSalary and DepartmentName) . I want to import these fields to a Datagrid view in my application and to database also. Pls help me with code of this application... I am using C# windows application .....
Just a backup
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
|
Posts like that will never get any useful reply. It's even worse when you post it twice in a period of 1 min.
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
This has been asked many times on this forum so use search before asking questions
|
|
|
|
|
i couldnt find any article tht related my problem..
|
|
|
|
|
That's a load of crap, there is at least 100 posts on that topic in this forum, and quite a few articles.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
would you like anything else your excellency?
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
I'm using .net 1.1
Now I have tried with the code:
System.Text.ASCIIEncoding encoder=new System.Text.ASCIIEncoding();
byte bytes=encoder.GetBytes(p_strXmlFrag); //Here its giving error
MemoryStream ms=new MemoryStream(bytes);
XmlWriter writer=XmlWriter.Create(ms); //Here it could not find create method
ms.Position=0;
XmlTextReader.xmlFile=new XmlTextReader(ms);
----
----
----
----
------------------------------------------------------------------------------------------------------------------------------------------------------------------
I'm also pasting the total method code to make it clear:
public static bool Validate(string p_strMmlFrag, out string p_strErr)
{
p_strErr=string.Empty;
//starting of if statement
if m_xsc==null)
{
m_xsc=new XmlSchemaCollection();
try
{
string path=AppDomain.CurrentDomain.BaseDirectory+m_strSchema;
if (!File.Exists(path))
{
path=AppDomain.CurrentDoamin.BaseDirectory+"/bin"+m_strSchema;
}
XmlTextReader xmlFile=new XmlTextReader(path);
m_ifSchema=XmlSchema.Read(xmlFile, new ValidationEventHandler (ValidationCallBack));
//Error rises in the above line as the destination file path (stored in path variable), I have just created (the file) and it's definitely empty. I tried the above mentioned solution but it's giving error!!!!!!!!
m_xsc.Add(m_ifSchema);
}
// ending of if statement
catch
{
-----
}
-------
------
-------
------
private const string m_strSchema="StructureLinkage.xsd"
private static XmlSchemaCollection=m_xsc;
private static XmlSchema m_ifSchema;
// For the first time only m_xsc in null and after that it does not need to enter into above block of code once m_xsc is instantiated.
}
|
|
|
|
|
Hi,
some suggestions:
- read the documentation on the classes you intend to use; that is what documentation
is for;
- XmlWriter.Create() does exist and has many overloads
- show your code in PRE tags, that makes it easier to read
- when a compile error is generated, show it exactly as it is shown to you
- when (later, if it ever will build) an exception occurs, show it with
myException.ToString() and show the outcome in your message
- encoder.GetBytes(p_strXmlFrag) returns a byte array, not a single byte that
you like to call "bytes"; so the destination must be of type byte[]
- don't call your problem urgent, if it is urgent it only means you started too late.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
|
Hi
iam uploading two separate sqlserver db files in first form.I want to list out tables in two dropdown list boxes from this two database in second form.Plz help me if u have source code it will be very useful.Thanks in advance.
|
|
|
|
|
Upload the files and attach the database using the sp_attach_db stored procedure in the master database. The open a seperate connection and query the sysobjects table in your database to retrieve all tables...
|
|
|
|