|
Within the *.designer.cs file there are several regions that are closed when you first open the file. The stuff you are after is in one of these regions.
Look for '+ Windows Form Designer generated code'. If you haven't changed the standard colour settings it will be greyed out. Click the '+' or right-click and select appropriately from the context menu.
If memory serves there is even a setting in Tools|Options to have them automatically expanded when you open the file.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
As far as I can work out, finalizers/Dispose methods are only used for unmanaged resources, correct?
Well I have this problem:
I have a class inherited from UserControl. The constructor creates a ToolStrip to be displayed on the control. When the control is no longer referenced it gets GC'd, and the ToolStrip should too.
However I noticed a memory leak with this and I found a thread on another forum explaining that a ToolStrip subscribes to the SystemEvents.UserPreferenceChanged event. This prevents the control from being GC'd since that event is referencing it. A way to fix this is to set the Visible property of the ToolStrip to false before the control has no references to it. This works.
But I want this to be done "automatically". So how do I write a "destructor" method that will set the Visible property when no references to the ToolStrip are left? I'm confused since this isn't really an unmanaged resource.
|
|
|
|
|
Hi,
yes, Dispose is typically used to clean up unmanaged resources, such as memory allocated by native code. And is normally not needed for dealing with end-of-life aspects of managed resources, as the GC will find and collect those itself. However, IMO nothing is keeping you from using the same Dispose method for hiding the ToolStrip.
Example: you probably know the using construct gets used to automatically Dispose of an object when the code block is exited. This is also used by stream I/O; StreamWriter implements a Dispose, so a using construct will call Dispose, which basically closes the stream.
using (StreamWriter sw = File.CreateText(path)) {
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
}
is an example in MSDN. Flush, Close and Dispose are all invisble; using calls Dispose, Dispose closes, and closing implies flushing first.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
OK, so this topic is relevant to a lot I'm doing at the moment. You say that Dispose is typically used to clean up unmanaged resources. But I've been reading up and getting conflicting opinions on what to do with dispose.
Do you have any good articles / best practices for how to use dispose? Say I create a Linq DataContext for the lifetime of my object, do I call Dispose on my context in my own dispose method or is there a better technique there?
|
|
|
|
|
Hi All,
I'm trying to create a table in a windows program but was not able to find the control that would allow me to do so. I would like to create a table that looks like the HTML table. I have tried using List View and turned on the grid. I've noticed that it is not possible to control the number of desired table rows, table height, and grid line thickness using ListView with grid property set to true. I'm planning to pull information from a text file into this table and then print it out. This is for a windows application not a web application. Please point me in the right direction, thanks in advance for your help.
|
|
|
|
|
Have you looked at the DataGridView? I used two of them in CP Vanity[^].
If you like it, make sure you test a print before you commit; it may be tricky, I don't know for sure.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Pls i have a project i want to distribute,
i want to add product key to it such that it is requested during the program installation,
i need on this please.
thanks
|
|
|
|
|
You can simulate the trial key by reading and writing registry. Firstly, set a value in registry, when loading the application, read the registry and check if the user has the valid value which matches up the value already saved in the registry.
For some basic knowledge about registry, you can refer to this blog post.
http://devhood.com/tutorials/tutorial_details.aspx?tutorial_id=264
You'd probably be best to look at a commercial setup creator for that sort of functionality
Here's a list of commercial installers. Pretty pricey for the most part.
http://www.csharp411.com/net-installers/
|
|
|
|
|
Use the search box at the top of this forum to search the Code Project Articles for product key, there are several quite good articles on the subject.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
Henry Minute wrote: Use the search box ... for product key
Lost your key again?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Have you seen my slippers?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
If you just heard the sound of breaking glass, you probably have stepped on your spectacles, and put your slippers on the top of your head.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
That's a hell of a visual, Luc, and brings to mind visions of my 80 yo mother... She's sharp as a tack, but she has her entertaining moments.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I'm not sure why, but knowing Henry for some time now, he often reminds me of professor Zonnebloem[^]. I've enjoyed reading all his adventures.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
How perceptive of you Luc.
Visually quite accurate, except for the hair colour where I am more Snowy than Calculus!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
OK, I'll have to correct that image then.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi All
I did a function for doing a screenshot of the WinForm application I am doing now.
This function is run when the user click on a item of the main menu of the form ( MenuStrip ).
The point is that in doing this way the screenshot foo is called with the menu still open so the image includes also the open menu;
because of this I need to call the function right after the menu item gets close.
Do you know what could be the event?
I tried Drop DropDownClosed but it doesn't work.
Do you know what event fit my issue?
Thank you very much.
Regards
Mn
|
|
|
|
|
AFAIK there is no such event. What happens if you wait 50 msec before taking the snapshot?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thanks!
Simple solution that works nice.
It is true..i was not able to find such event
AFG
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Have you tried using the DropDownClosed event for the parent of the menu item in question? I'd probably set a flag in the item's Click event, then check it in the parent's DropDownClosed event and do your screen capture after the drop down menu has closed.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Yes and it doesn't work. I solved doing the screenshot 50 ms after the click.
|
|
|
|
|
I'm a little confused.
You say
manustone wrote: The point is that in doing this way ... the image includes also the open menu;
Then you say
manustone wrote: I need to call the function right after the menu item gets close
If you take the screenshot right after the menu is closed, how will the screenshot have the menu opened? Which do you want? Do you want the screenshot with the menu open or without the menu?
If you want to include the menu in the screenshot, I would create the image during the MouseDown and then save it during the Item_Click like so:
private Bitmap bmpScreenShot;
private Graphics gfxScreenShot;
private void takeScreenshotToolStripMenuItem_Click(object sender, EventArgs e)
{
bmpScreenShot.Save(@"D:\temp\screenshot.png", System.Drawing.Imaging.ImageFormat.Png);
}
private void takeScreenshotToolStripMenuItem_MouseDown(object sender, MouseEventArgs e)
{
bmpScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
gfxScreenShot = Graphics.FromImage(bmpScreenShot);
gfxScreenShot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0,
Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
}
If, however, you're trying to do something after the menu is closed, you could handle its parents DropDownClosed event.
|
|
|
|
|
So, the screenshot captures the drop down and you want to find a way to get the screenshot without the dropdown? But you want it to be taken right after an item in the drop down is captured?
Perhaps you could try doing a Refresh() on the form to force it to redraw itself and then perform the screen capture. You might also initiate an asyncronous event via this.BeginInvoke and have that event take the screen capture.
|
|
|
|
|
how can i bind checklistbox control with object in memory in asp.net
|
|
|
|