|
Thank you for answer, I have already done it same way, but without if statement, so I have just added it and it's working a little better. So thanks, again.
Greetings,
Dawid Mazuruk
|
|
|
|
|
Hello,
Can you point me out in some directions of how to create a thumbnail of the currently opened web page in my browser, something similar to what Alexa is doing? I would like to loop through all my web site templates and generate a gallery web page.
Thank You,
Razvan
drinking beer is fun
|
|
|
|
|
I've got a feeling that the WebBrowser control allowed you to draw the rendered page to a bitmap. Perhaps that'll help.
|
|
|
|
|
Thank you Ed!
Indeed the web browser has a function - DrawToBitmap which is hidden to the intellisense. Although the summary of the functions states that the function is not supported by the web browser it works very well for all my local templates, but when trying to make a thumbnail of codeproject or yahoo the image returned is blank but strangely enough google.com works
drinking beer is fun
|
|
|
|
|
Hello, I am using the TreeView control (version 2.0) in a Visual Studio 2008 Windows application. Everything works fine on the development computer but when I deploy the program to the client's machine the control produces the following error when the user makes a few clicks on the nodes:
/////////////////////////////////////////////////////
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.DivideByZeroException: Attempted to divide by zero.
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.TreeView.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.TreeView.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
CarRent
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/ISS/CarRent%20Setup/CarRent.exe
----------------------------------------
////////////////////////////////////////////
I couldn't find any reasonable cause for this error, and I couldn't catch it! I surrounded all my code with try/catch blocks and none of them was able to catch the error!
One more thing to mention, the project that contains the control was originally developed in VS 2005 and then converted to VS 2008 format (I don't know if this has anything to do with the error, but I mentioned it, just in case).
|
|
|
|
|
What's the code in your treeView's MouseDown/MouseClick/Click methods?
|
|
|
|
|
That's weird.. it looks like a DivideByZeroException...~!
Is the code dividing values? Maybe you could set up an if statement to say if the denominator is 0 then throw a custom exception?
Have you tryed using the step-by-step debugger to see what line is throwing the exception?
Mark.
|
|
|
|
|
I have had this error before when using mono...
The scrollbar in the treeview (I beleive), whilst trying to calculate its position and size, is causing the divide-by-zero exception.
I think I solved this by setting the scrollbars to be always visible.
But as I say, this was with mono so this may not work under your circumstances.
(You could try installing the latest verion of .net on the target machine).
Hope this helps.
Matthew Butler
|
|
|
|
|
Hi,
I want to compare Empty String but confused, which method is more performant, I have 2 solutions. would you please let me know which solution to choose ? Solution 1 or Solution 2 ?
Solution 1:
--------------
string a = TextBox1.Text;
if(a == String.Empty)
{
}
Solution 2:
---------------
string a = TextBox1.Text;
if(a == "")
{
}
|
|
|
|
|
Neither.
They perform equally, but both your solutions do a string comparison, which is unnecessary. You only need to check the length of the string:
if (a.Length == 0) {
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Thanks,
So, you mean, checking length ==0 is more performant than comparing with empty string, right ?
By the way, if I use,
if(a.Trim().Length == 0)
then, am I causing same performance cost as (a.Trim() == "") ?
|
|
|
|
|
bashiwala wrote: So, you mean, checking length ==0 is more performant than comparing with empty string, right ?
Yes. Comparing strings aren't very expensive, but it still involves things like getting the culture info to use for the comparison. Comparing the length is a simple integer comparison.
bashiwala wrote: By the way, if I use,
if(a.Trim().Length == 0)
then, am I causing same performance cost as (a.Trim() == "") ?
No, checking the length is still somewhat faster than comparing two strings.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hi,
Thanks for your suggession. I just found some exception where comparing Empty String is necessary than comparing zero length.
For example, I am checking if any Key in a NameValueCollection is Empty or not,
I can check like this,
if(MyCollection["myKey"] == String.Empty) ...
this works fine if the key does not exist, but if i use
if(MyCollection["myKey"].Length == 0) ...
then I get Exception "Object Reference Not set to an instance of an object"....
Same result I got when I check the Emptyness of a string value property like this
public string myProperty
{
get { return "hi";
set { if(value.Length == 0) ...; } // Exception is thrown, but if I use value == String.Empty, it works..
}
|
|
|
|
|
Do you really mean that if the value is null, you want to use the value?
Otherwise, there is a method in the string class for checking if a value is null or empty:
if (string.IsNullOrEmpty(MyCollection["myKey"]) ...
set { if (string.IsNullOrEmpty(value)) ...; }
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
But in that case you should check MyCollection.ContainsKey("myKey") before trying to reference the value.
Plus, won't if(MyCollection["myKey"] == String.Empty) return false ? The same as a non-empty string?
|
|
|
|
|
There isn't any performance difference. Checking if the string length is 0 is probably the better way to go, as Guffa said.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
i think
TextBox1.Text.Trim().Equals(string.Empty)
would be a better option
|
|
|
|
|
If you are using .NET 2.0, you could use System.String.IsNullOrEmpty(a) .
-----
You seem eager to impose your preference of preventing others from imposing their preferences on others. -- Red Stateler, Master of Circular Reasoning and other fallacies
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
God is the only being who, to rule, does not need to exist. -- Charles Baudelaire
|
|
|
|
|
|
how i have a gridimage for load map with episodic block in c#
i have a map blockly
i want with mouse move on map load block
please help me
|
|
|
|
|
Ok now i am creating a button to send data to a website with POST method
it works fine but the problem is when i press the button it shows me invalid referrer
Is there anyway to change webBrowser referrer?
|
|
|
|
|
Hi,
I'm trying to unbox a value stored in ViewState using the code below:
I can't seem to figure out what I'm doing wrong, can someone please perhaps point out what I'm doing wrong or perhaps an alternative?
<br />
(Int32)ViewState["totalLightsWatt"] = ((Int32)ViewState["totalLightsWatt"]) + (Int32.Parse(txtLightsQty.Text.Trim().ToString()) * Int32.Parse(cboLightsItems.SelectedValue.ToString()));<br />
Thanks.
R
|
|
|
|
|
hi,
you can't cast the left hand side, just drop the first (Int32) .
If your expression (that is the right hand side) does not have the type required by
the left hand side, make sure it is in parentheses (it is now) and cast it as in
ViewState["totalLightsWatt"] = (viewstatetype)(....); .
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi Luc
Thank you very much for your reply.
Your solution made my error very clear and I get what I did wrong now.
Thanks once again.
|
|
|
|
|
hi
how can i attach file to mail and send it using c# code ?
thank's
|
|
|
|