|
I've been wondering this for a while...
When I create something in the IDE - a form with buttons and boxes and other widgets - I usually spend a great deal of time setting the properties of each item. Obviously VS saves those properties somewhere, else it would be impossible to remember them after I close the session. But where? The Designer file only stores declarations; that's the first place I looked. But out of curiosity I've opened every file in Solution Explorer to locate these property settings, and I can't find a hint of them. Since I don't believe in magic, there must be some other way for the IDE to keep track of the properties I've selected. But where?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Roger Wright wrote: The Designer file only stores declarations; that's the first place I looked.
Look again. Make a button, set some properties, then open the designer file. Go to the button declaration and do a "Find All References" on it. The properties are set in the Designer file.
|
|
|
|
|
Ah, Luc hit it on the button - the regions needed expanding. It's all there. Thanks!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
In my projects, the properties all appear to be set in the *.Designer.cs files
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Silly me, I didn't expand the regions in the file... [whacks forehead]
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hi Roger,
several files are created for you, next to the regular source files you create yourself:
for a solution abc there is an abc.sln file, it is a text file pointing to the projects;
and an abc.suo file, it is a hidden file, holding binary data.
for a form xyz there is a xyz.designer.cs or xyz.designer.vb holding declarations and initialization code;
there are settings files
there probably also are resource files, depending on your usage of resources.
Most of the simple stuff you enter through Visual Designer goes into the designer.cs/vb files.
As it uses regions, you'd have to open up the regions (or disable outlining) to see all of its content.
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).
|
|
|
|
|
Wonderfully informative, as always Luc. Thanks! I forgot to expand the regions, since I never use them myself.
Sometimes I wonder if I might have better luck learning this stuff sober, but then I remember all the nuclear missile design work I did on bar napkins. That all worked out okay, so why change strategies now?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
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).
|
|
|
|