|
???
a catch block only catches one Exception. Why do u whant to loop and where?
I don't understand your request
spif2001
|
|
|
|
|
Hi,
Here is one example for SQLError
try
{
some code
}
catch(SqlException ex)
{
foreach(SqlError sqlError in ex.Errors)
{
some code
}
}
Sometimes you get more than one exeption at the same time ( especially SQL for example )
|
|
|
|
|
hi,
As was already mentioned, catch "catches" only one Exception. I think you are trying to do something like :
<br />
try<br />
{<br />
if(stg)<br />
{<br />
myBadFunctionThrowsMySpecificExcpetion();<br />
}<br />
else<br />
{<br />
i= i/0;
}<br />
}<br />
catch(MySpecificException ex)<br />
{<br />
}<br />
catch(Exception ex)<br />
{<br />
}<br />
When exception is raised in try block, it is catched in "closest" catch if throwed exception is (in meaning that operator is would return true - same type or derived class) the same as declared in catch block. If exception of diferent type is thrown, then it passes thru first catch block to another (if present),.. etc. You must write catch blocks from specific to most generic; if you wrote catch for System.Excpetion first, all exceptions would be handled in this block. No other would have chance to trap error.
I only hope this is answer to your question
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
You are close to the problem, but i want get all error messages from all risen errors there. In the last message I have wrote an example for SQL tasks. Here it works, because you can assign a specific error, so I think it shpuld be possible to loop within all possible errors ( I need the name for the element and elements-> foreach(element in elements))
|
|
|
|
|
how about:
try
{
}
catch(Exception e)
{
Exception ex = e;
while(ex != null)
{
Console.WriteLine(ex)
ex = ex.InnerException;
}
}
|
|
|
|
|
Hi,
A question:
How can I create a popup with a textbox or a combobox in it?
e.g. in MS Access 2003 there is such a thing if you do
a right click on a table column to add a filter...
Thanks in advance!
Hornox
|
|
|
|
|
Don't know if the following will work, but maybe you'll give it a try.
Create a simple Form, which contains the TextBox, ComboBox or whatever you want.
Catch the MouseDown or MouseUp event of the controls ,which should open the popup form after a right-click on them, and determine whether the right button was clicked.
If so create an instance of your form, assign the mouse coordinates to the Location property of your form and show it.
www.troschuetz.de
|
|
|
|
|
Hi All,
How to spawn a UI Thread in C#.
I want to show window having ProgressBar while starting application(from main window constructor),application takes some time to start.
The window having progressbar should run in different thread having it's own message que and all.
Thanks
TusharM.
|
|
|
|
|
Maybe try it the other way around. You have a "splash" type screen which is your main constructor. It can load fast as it is small. It fires off a thread that starts the loading of the main app which uses delegates or some such to report back on the loading progress.
Here is an article that may help you out; A Pretty Good Splash Screen in C#
regards,
Paul Watson
South Africa
The Code Project
|
|
|
|
|
You can use Application.Run more then once in an Application.
Try creating new splash form, pass it to Appication.Run method
then run your main form (Application.Run(new MainForm());)
When you need to close the splash screen just close the splashForm
(splashForm.BeginInvoke(new MethodInvoker(splashForm.Close));)
|
|
|
|
|
Hi
I have created a dll in vc++ 6.0 from where i want to send a specific message to my c# application and than want to handle that event in my c# front end
further i am also using that dll in a web seb service in c# that is used in an interface developed in vb.net.
is it possible to send my custom message from vc++6.0 dl to c# web service.
Waiting for ur responce
Thanks.
|
|
|
|
|
I have made a Custom Control and I'm having troubles in design time - I have omitted the Dispose method to the ABox in the code below.
Using the following code in design time (adding an ABox to a Form), i can change the MyComp.MyText property in the property editor and the Text property on my ABox will change.
But I can't change the MyComp.MyList property and make it change the ABox' Items values. It works in RunTime but not in design time.
How come?
Any and all ideas would be very welcome.
spif2001
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace AgroTest
{
public class ABox : System.Windows.Forms.ComboBox
{
private System.ComponentModel.Container components = null;
private MyComp myComponent;
public ABox()
{
InitializeComponent();
this.myComponent = new MyComp(this);
}
[Category("AgroTest"), System.ComponentModel.DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public MyComp MyComponent
{
get
{
return this.myComponent;
}
}
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
}
}
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Collections.Specialized;
namespace AgroTest
{
[TypeConverterAttribute(typeof(ExpandableObjectConverter))]
public class MyComp
{
private ABox owner;
private StringCollection myList = new StringCollection();
private string myText = "!!";
internal MyComp(ABox owner)
{
this.owner = owner;
}
[Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design",
typeof(System.Drawing.Design.UITypeEditor)),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
DefaultValue(false)]
public StringCollection MyList
{
get{return this.myList;}
set
{
try
{
this.owner.Items.Clear();
foreach(string s in value)
{
this.owner.Items.Add(s + "!!");
}
this.owner.Invalidate();
this.myList = value;
}
catch(Exception){}
}
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
DefaultValue(false)]
public string MyText
{
get{return this.myText;}
set
{
try
{
this.owner.Text = value;
this.owner.Invalidate();
this.myText = value;
}
catch(Exception){}
}
}
}
}
|
|
|
|
|
Hi,
Try calling the InValidate() method, even after you set the value in the property.ie,
In "public StringCollection MyList" and "public string MyText", in the set block , call Invalidate after u set the value to MyText.
Try this and let me know...
Regards,
Manivannan
|
|
|
|
|
Sadly it had no effect - thanks though
|
|
|
|
|
Hi i'm new to C# and i'm trying to create a telephone Call Record on a datagrid but i couldn't get anything displayed on my datagrid. Though i assigned my datasource to be my call records. I was just wondering if anybody can give me a little lecture on datagrids.
Thanks.
|
|
|
|
|
Could you post some code as to how you are assigning the datasource? Is this a windows form app or a web app?
|
|
|
|
|
I want to get and set ShortDate format from control pannel setting.how can i do in C#.
Pls answer me.
|
|
|
|
|
I can only point you in the vague direction of the Globalisation namespace of .NET. This article mentions changing the CulterInfo (which is what you want) of a thread.
regards,
Paul Watson
South Africa
The Code Project
|
|
|
|
|
hi,
i need to create new tabpage in runtime by user action. and, each tabpage should be the same with same controls. i draft a Panel User Control. i planned to use it to insert in the tabpage dynamically.
anyone have idea on this issue?
thanks,
jim
|
|
|
|
|
Try this:
1. drag and drop a textbox ctrl, a button and a Datetime picker.
2. run the application and press tab . u can see the focus in each control including DTpicker.
3. Just select another date in the dattime picker using that combo.
4. now press tab , u will see that DTPicker doesnt receive the focus....
help me if u can brin the focus ....
regards, Mani
|
|
|
|
|
hello i am creating a docking window class and so far it all works and im just using the regular dock property and it inherits from Form when my form is docked to the parent and is resizable i can resize it however when it loses focus it snaps back to fill the parent i tried saving the size in the resize event and setting them in both paint and deactivate events however neither will retain the size what can i do to make it save the size when it gets resized.. i am using similar code when it is not docked and that works fine
|
|
|
|
|
i am new to win ce application i have a small pocket pc application i want to create .MSI file for my application. i have three projects in one solution myapplication project,custom installer(empty project),setup project i have added a installer class file for CustomInstaller project and modified it with some code, but i am getting the following error when i build the Custom Installer project. The error is
"Pre-Build Event Faliled"
please help
regards for any help
Any comments please mail to chatcops007@yahoo.com
|
|
|
|
|
Try this article here on CodeProject:
http://www.codeproject.com/netcf/compframe4.asp
hope it works - it did for me...
spif2001
|
|
|
|
|
Look at your project properties to see what the pre-build event is (if you don't already know). Whatever it is (batch file, script, etc.) you can try running it separately, from a command prompt and proceed to debug it. The article refered to by spif2001 has a batch file, for example.
Additionally, if the script has any error output, you should be able to see it in Visual Studio's "output" window.
By the way, I think you get that message whenever the specified script returns a non-zero errorlevel.
Matt Gerrans
|
|
|
|
|
How can you do this for other browsers like Netscape or Opera? Can this be done for other browsers?
http://www.codeproject.com/useritems/iemozilla.asp[^]
If it has been done can you tell where I can learn more about this or other good resource sites.
Thanks,
|
|
|
|