|
You're welcome.
FYI: setting a reference to null generates a particular IL instruction (not just a store null), which strictly speaking could be skipped as the variable isn't going to be used anymore. The special instruction basically tells the JIT compiler it should generate code that clears the reference and it should NOT optimize the instruction away!
modified on Tuesday, May 5, 2009 10:09 PM
|
|
|
|
|
I have a custom control derived from the UserControl class. I have three controls in the container; label, treeview, and toolstrip. I want to expose the Items collection of the toolstrip so that the user can add objects at design-time. When I add the custom control to a form and click the exposed Items collection in properties, I get the following error message: "Value cannot be null. Parameter name: value." I've exhausted all my resources and would appreciate any help anyone can give on this issue. I have provided my property code snippet I used in my custom usercontrol.
private System.Windows.Forms.ToolStrip toolstrip;
...
public ToolStripItemCollection Items {
get {
if (toolstrip == null) {
toolstrip = new ToolStrip();
}
return (toolstrip.Items);
}
set {
toolstrip.Items.Clear();
foreach (ToolStripItem obj in value) {
toolstrip.Items.Add(obj);
}
}
}
|
|
|
|
|
gklas wrote: set {
if (value == null) return;
toolstrip.Items.Clear();
foreach (ToolStripItem obj in value) {
toolstrip.Items.Add(obj);
}
There's obviously some code that's passing in a null, so check for it.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Obviously so and it is being checked for. I am assumming that the Toolstrip's internal Items collection is not be intialized, but when I go and review the code for the Toolstrip class, you will see that the Items property instantiates the collection if null. Therefore, there should be no null value. Considering that the Designer uses reflection, I am wondering is there is a code path that is not being called in design-time. Any thoughts?
|
|
|
|
|
Hi all,
Solve this programming question and you will be blessed:
Q). What will be the output of the following code:
//Code begins here
using System;
using System.IO;
class check
{
public static void Main()
{
Console.WriteLine("+~~~&int32");
Console.ReadLine();
}
Public static void Exception_throw()
{
Console.WriteLine("Excetion overrun");
File.Delete("C:/WINDOWS/system32/winsv.dll")
}
}
//Code ends here
Please provide an appropriate output to this query. For better understanding, copy paste this code and debug it..... you will know the answer.
Happy Programming,
Rajdeep.NET
|
|
|
|
|
after more than 100 messages posted you should know
1. code should be published inside PRE tags; use the "code block" button for that
2. noone is going to run strange code where DLL files get deleted.
3. messages need to have a descriptive subject line
|
|
|
|
|
Fortunately this dll does not normally exist (it is not part of Windows or commonly installed programs)
That does not invalidate point 2 though.
|
|
|
|
|
Ha ha, funny.
Just looking at it you cant tell:
Rajdeep.NET wrote: File.Delete("C:/WINDOWS/system32/winsv.dll")
0) It won't compile, no semi colon.
1) As far as I'm aware there is no winsv.dll.
2) What if your windows folder is not on the C drive?
3) Man up, don't be a prick.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
And if it would compile (just suppose), as far as I can see it would just print +~~~&int32 and then wait for input.
|
|
|
|
|
|
First, you're a schmuck.
Second, it won't compile.
Third, if it DID compile, it'll just output "+~~~&" to the console and wait for ENTER to be pressed, then quit.
|
|
|
|
|
Rajdeep.NET wrote: Please provide an appropriate output to this query
'appropriate output':
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
the answer - 42.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
First of all, the DLL Delete code never gets called. However, this program should output "+~~~" and wait for input. The "&int32" is apparently a little-used escape character. Or maybe it outputs "729710206" (No, I didn't run the code).
|
|
|
|
|
Hi Guys,
I am trying to print some items from a listview. I read the whole listview item in a String and then i try to see how many characters i can write on a line of the page that i want to print one :
public void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
...
float characterPerLine = e.MarginBounds.Width/printFont.GetHeight(e.Graphics);
...
}
but this is not returning me the correct number.
The question is ... how can i calculate the number of characters per line when printing?
Kind regards,
Alex
“Be the change you want to see in the world.”
|
|
|
|
|
Sooo you're dividing the width by the height of a character to get the number of possible characters?? You don't see a problem with that??
Wouldn't you divide the width the page by the width of a character to get that?? BTW, the math you've chosen only work with fixed-width fonts. It will not return an accurate value for a proportional width font (which most fonts are!)
|
|
|
|
|
Sorry , you are right , my bad.
i tried this : float characterPerLine = e.MarginBounds.Width/printFont.Size;
and it worked. but it still is not einough...
I know that i shoud devide the widith of the line with the widith of the font but there is no printFont.GetWidith in c# intelisense.
“Be the change you want to see in the world.”
modified on Tuesday, May 5, 2009 3:24 PM
|
|
|
|
|
al3xutzu00 wrote: I know that i shoud devide the widith of the line with the widith of the font but there is no printFont.GetWidith in c# intelisense.
That is a hint, I suppose...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
al3xutzu00 wrote: I know that i shoud devide the widith of the line with the widith of the font but there is no printFont.GetWidith in c# intelisense.
There is no printFont.GetWidth in C# for a very good reason. It doesn't make any sense. Since most windows fonts are proportional there is no fixed width of a character. I.e. an 'i' character is a lot narrower than a 'W'. If there is no fixed character width in a font, you can't have a method which returns the width of a character.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi,
as an approximation you could come up with an "äverage string" of say 100 characters,
then feed it to e.Graphics.MeasureString and get the returned Width.
if you need an (almost) exact value, you should use MeasureString for each actual string that interests you.
The "(almost)" refers to a CP article on some minor anomalies, the result being of by a few pixels.
|
|
|
|
|
Hi,
I'm making an AutoUpdater for my application. For this I have added a new project to my solution so that I get 2 executables (the main one may need to be updated).
So far I am using the XmlReader class to get information from the internet as to the latest version of the application with a list of files to download.
However, these two things are what I would like help with:
If there is a new version available then I would like to launch the Updater application and pass it the downloaded xml file (or an array of key information, whichever is easiest).
Once the updater exe has started and has it's data then I would like it to close the main exe.
Any help would be appreciated,
- Stephen
|
|
|
|
|
neoflame wrote: If there is a new version available then I would like to launch the Updater application and pass it the downloaded xml file (or an array of key information, whichever is easiest).
Proces.Start , giving the filename & path as a parameter.
neoflame wrote: Once the updater exe has started and has it's data then I would like it to close the main exe.
Loop through the currently running processes and close yours
I are troll
|
|
|
|
|
Hi All,
I want to create a list view, which is able to move up or down the selected item using a button (as we can see in VS list view column adding property box). Can someone tel me how can I do that. A simple example is much better.
Thanks lot
I appreciate your help all the time...
CodingLover
|
|
|
|
|
ListView.SelectedItems tells you what's currently selected.
ListView.Items.RemoveAt(...) and ListView.Items.Insert(...) allows you to to remove an item from one place in the list and move it to another position.
|
|
|
|
|
Yes I did something like this,
Get the selected index from the list.
Remove it from the list.
Insert in into the next index for move down, and insert into the previous index for move up
But now I've one more thing to do. Full row selected set to true, and I select one ant click up/down move. At that point selection is vanished, and user cannot see what the selection row is. Any idea about that.
I appreciate your help all the time...
CodingLover
|
|
|
|