|
Thanks. I was only using the Category, Description and Default attributes. Adding the Browsable and EditorBrowsable attributes did the trick.
Now that I've got it showing, testing has shown a couple other nuances.
1. Using Default doesn't do anything, it always contains the default object name as the default Text, regardless of the Default attribute. Even setting a line after InitializeComponent(); as Text=""; , didn't do anything.
2. I would've been able to live with the Text property not being blank upon dropping the component on the form but not remembering its value just ain't cool. Initially I tried to use base.Text as the storage for the Text value (seemed the appropriate thing to do). Close the form and open it, the Text value is gone. Tried using a private variable instead, got the same result. Tried using new rather than override in both scenarios of base.Text and a private variable. The component still will not remember the value of Text. None of this affected Default either.
While answering this, can you tell me if there is a trick to finding info in the Help and/or SDKs? I suspect the answer you provided would've been there but, while there is probably everything I need to know at my finger tips, asking the right question seems to be the issue (thus RTFF seems to be a better solution than RTFM). Unfortunately, due to corporate bankrupcies I no longer have the team with which to collaborate (previously coded in Delphi) and some of the nuances of .Net have been somewhat frustrating to decipher.
Thanks again.
|
|
|
|
|
These are all design-time attributes. The DefaultAttribute is there to facilitate resetting the property value. Using a method that returns a bool called ShouldSerializePropertyName also facilitates this goal.
Again, though, don't use new . Only use this when you want to hide a member. For instance, if you use new , any code that refers to your class as a Control (where Text is defined as a virtual method) or any other derivative of Control (before your class), then the virtual Text is used. Only when a variable is declared as your Type will your Text be used. Since much of the Windows Forms implementation refers to all child controls as Control types, your Text accessors wouldn't be called.
To note (since you obviously read the little flame war that shouldn't have been), I don't completely advocate RTFM. RTFM goes well with RTFF, but I'm a strong believer in teaching a man to fish, if you know what I mean. Reading the docs and understanding them (like the mostly consistent naming conventions, how C# relations to .NET and IL relates to the CLR, etc.) is very important, but there's also times when people get stuck - even the best have brain farts now and then.
The best thing to do is just skim the class library docs some time. Get to know where everything is. Also, whenever you have a question about a specific class, the help Index is your friend. Just type it in. Don't specify certain properties, though, like ScrollableControl.Text because it doesn't exist as a defined method of ScrollableControl - it's inherited. It will be in the member documentation for ScrollableControl but not in the index. It's just the way their help built system works (and even those like NDoc[^] which I occassionally contribute to and is very popular).
Once you get to know where all the classes are roughly and how everything is named, it's not too hard finding what you need if you can't remember or even if you don't know exactly what you're looking for.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
this isn't directly c# linked as it can be applied to a lot of other languages, but there you go. when developing applications what do people normally name their versions as? major.minor.revision or also build number etc. i'd be interested to hear the standard or if there is one at all. also how do you cope with making patches (if you need to! ) surely you wouldn't have to release a new program each time and send it?? can't you have some some of file that updates the original?
cheers,
surgeproof
-------------------------------------------------------
looking for hosting? ithium is good.
|
|
|
|
|
As far as version numbers go, that kind of depends on how you build the app. What I prefer, is to have a nightly build process with version numbers that are <major>.<minor>.<months><days> . Any builds outside of this would be the same, appending .<24hr time> , or some other unique identifier. The <months> and <days> represent how many months and days you've been working on the <major>.<minor> version.
If I'm not using a scheduled build, I usually just do <major>.<minor>.* , which lets .NET decide what the rest should be. For larger apps, or those with frequent changes, that don't have scheduled builds, I'd do <major>.<minor>.<revision>.* .
Michael Flanakin
Web Log
|
|
|
|
|
thanks, this helps. any ideas about the upgrade/patch routine? and also, do you name all the version yourself or incorporate it into the code? can't you type something like version.major in your code?
once again,
thanks.
surgeproof.
-------------------------------------------------------
looking for hosting? ithium is good.
|
|
|
|
|
You specify the version of the assembly using the AssemblyVersionAttribute . You can also increment the version of only the file - keeping the assembly version, which is what is used for Type references, the same to facilitate easier updates - by using the AssemblyFileVersionAttribute .
For instance, .NET 1.0 uses the assembly versions 1.0.3300.0, but the file versions (as of SP2) are 1.0.3705.228. If you examine your MANIFEST in your assemblies that target 1.0, you'll always see assembly references to versions 1.0.3300.0 for .NET 1.0 (1.0.5500.0 for 1.1).
All this is to facilitate side-by-side installation of both the .NET Framework versions and applications that use these versions. In many cases, applications can work on newer frameworks for which they were compiled so long as you don't use obsoleted functionality and don't use reflection to access private members (you may get lucky and it may still work, but it isn't gauranteed).
To learn more about versioning your apps - including how to redirect assembly bindings to newer or older assemblies, read the following articles:- How the Runtime Locates Assemblies (Step 1 especially)[^]
- Redirecting Assembly Versions[^]
- Creating a Publisher Policy[^]
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks, this helps!
surgeproof.
-------------------------------------------------------
Science without religion is lame, religion without science is blind. --Albert Einstein
The pioneers of a warless world are the youth who refuse military service. --Albert Einstein
A question that sometimes drives me hazy: am I or are the others crazy? --Albert Einstein
|
|
|
|
|
I'm not sure what the best solution for patches is. I would think that, if you have a modularized application, where you might have a bunch of DLLs and/or EXEs, you could have a patch that would replace whatever needed to be updated. Other than that, I'm not sure. I've never done a patch process before. Most of the stuff I've worked with has been either small Win Forms or Web Forms, which don't use patches - they just deploy the new version.
And, as far as setting the version, I'm not sure. I didn't do that part. I want to say that there was something that was based off of either the source control or build tool. NAnt is supposed to be a good build tool. I haven't played with it myself, but am hoping to get a chance to give it a good look.
Michael Flanakin
Web Log
|
|
|
|
|
Hi,
is it possible to have an transparent Label on top of a progressbar, so that I can still see the progressbar?
Setting the color of the label to transparent does not work - at least for me. The progressbar still is not visible trough the label, neither in the ide nor in the exe. Moving the label in front of another label will make it transparent - so it seems like a progressbar-related problem.
Any idea?
regards,
Dennis
|
|
|
|
|
not sure, i would've just thought you set it transparent like you've done. :s
-------------------------------------------------------
looking for hosting? ithium is good.
|
|
|
|
|
If your goal is display a message while the progress bar increments (like the percentage, which was common with older controls), you might be better off just extending the existing ProgressBar and provide your own painting by overridding OnPaint (do your drawing after calling base.OnPaint to make sure that the progress bar itself is draw first and your code gets drawn on top of it).
Getting the label to be transparent actually has to do with the parent forum in which it's contained. This only works in Win2K and newer (i.e., XP, 2003) since it uses layered Windows, "Windows" (or forms, dialogs) being the optimal word. A transparent color or alpha value is specified for the form an any control that uses the same color (ambience) down the chain of child controls is transparent/translucent as well. Since the ProgressBar is not a form and would paint in different colors anyway, that's one problem (the reasons go deeper, but I won't get into that).
Your painting method could be as simple as:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int value = (int)(Value / Maximum);
string s = value + "%";
StringFormat format = StringFormat.GenericTypographic;
format.Alignment = StringAlignment.Center;
e.Graphics.DrawString(value + "%", Font, SystemBrushes.ControlText,
(RectangleF)Bounds, format);
} This is untested, but should work and at least give you some ideas.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you.
I already considered this solution, but still hoped for a Label-based solution.
Again, thanks for your help.
Regards,
Dennis
|
|
|
|
|
I have just joined a company that develops its own in house apps for call centre use but does not like using mice on the call centre floor. Has anyone got experience of developing .NET apps that do not use a mouse , but still use a winform based environment . If so , are there any big pitfalls to look out for ?
|
|
|
|
|
can't think of any pitfalls.
use tab orders, key press events and suchlike. it isn't too hard to do.
surgeproof
-------------------------------------------------------
looking for hosting? ithium is good.
|
|
|
|
|
Make sure that the tab order of the controls is logical. i.e. the tabs move through the controls in one logical group before jumping to the next.
.
. +--------+ +--------+ +--------+ +--------+
. | Ctrl1A | | Ctrl1B | | Ctrl2A | | Ctrl2B |
. +--------+ +--------+ +--------+ +--------+
.
. +--------+ +--------+ +--------+ +--------+
. | Ctrl1C | | Ctrl1D | | Ctrl2C | | Ctrl2D |
. +--------+ +--------+ +--------+ +--------+
So, in this example, you'd tab from 1A to 1B to 1C to 1D rather than go for a Left-To-Right-Top-To-Bottom reading order approach.
This is just the first thought that popped in my head. There was a thread in the lounge today on bad-design (Some of it was quite funny) so the second thought is: As you test the system with your nice handy mouse beside you - resist the temptation to use it!
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Also, assigning shortcut keys to menu items is easy enough. To handle function keys or even simple key strokes you can handle the various Mouse* events (or override the various OnMouse* handlers in derived classes for more efficient and controllable code). If you need to respond to keys pressed at any time while any window is open, see the Application.AddMessageFilter method and the corresponding IMessageFilter interface which you'd implement and handle the keys trokes you want (in which case the values match up with the Keys enumeration to make things easier) by handling the various keyboard notification messages (see the Platform SDK for values).
Finally, to have a form handle key strokes while any control has the focus, see the Form.KeyPreview property documentation.
Using all that, who needs a mouse?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, everyone
I am using a dll developped in VC6. There are some functions I don't know how to wrap it in C#.
1. one function's parameter use self defined type, type definition is like this:
#ifndef LPLONG
typedef long far *LPLONG; /* 32 bit */
#endif
2. one function's parameter use 'BOOL *'
3. one function's parameter use 'char *'
4. one function's return value use 'char *'
5. one function's parameter use a structure
6. one function's parameter use a structure *
How shall I deal with these?
Thanks in advance.
|
|
|
|
|
1. ref int
2. ref bool
3. [MarshalAs(UnmanagedType.LPStr)]string
4. [return: MarshalAs(UnmanagedType.LPStr)]string
5. Just pass the struct, but see the docs for the StructLayoutAttribute
6. ref YourStruct
All these - escept for 3 and 4 - are value types so you use ref or out (the latter if you don't need to pass any initial value to your functions). Don't use ref or out with a string because it is already a reference type. Both char* and char[] are strings since a string is only an array of characters. Since you're using char and not wchar_t (or TCHAR ), you must marshal them as ANSI strings.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How about void *? Thanks.
|
|
|
|
|
|
Hello,
I'm trying to create a property sheet in C#. My idea is:
Create several user controls (derived from UserControl class) that represents my property pages.
Create a windows form that contains one Panel object to use like a placeholder for the pages created above.
The problem is that I don't know how to add a UserControl to a Panel object. (perhaps it's not possible...)
If someone has any idea on how to do this please reply
Thanks in advance
Pedro
|
|
|
|
|
Add a TabControl to a form with a few Button s under it. Add your UserControl s to each tab. After compiling your project, the UserControl s should be available in the Toolbox. If not, add them manually by adding a private field for each Type and instantiate them and initialize them in the InitializeComponent method that the Windows Forms designers use. It's not difficult and the designers aren't magic. Knowing how to add this stuff without a designer is essential in good development skills.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
Thanks for your post!
The solution you gave works well, but I was looking for something like CPropertySheet and CProperyPage in MFC.
Is there any control that we can use as placeholder for other controls?
Thanks again.
By the way, I like programming with the keyboard, not with the mouse
|
|
|
|
|
That's not really what you asked for, though.
If you want a good implementation, see the IPropertySheet documentation in the Platform SDK on http://msdn.microsoft.com[^]. For example, I use a implementation similar to the following in our application:
public interface IPropertyPage
{
string Title { get; }
void Save();
void Cancel();
event PropertyChangedEventHandler PropertyChanged;
} Implement this type of interface on your control. Then create a PropertySheet class that allows you to add IPropertyPage implementations to it. When you call ShowDialog on your PropertySheet (should derive from Form ) it has all the pages in a TabControl . When the event is fired, enable the Apply button. When Apply or Save is clicked, call Save on each IPropertyPage in your collection and close the dialog if Save was clicked (it annoys me to no end when people click Apply then OK since OK is supposed to apply changes and close and - with all Microsoft implementations - does).
This is very similar to how MFC and the Windows Shell interfaces do it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello again!
That's exactly what I was looking for!
Thanks for your time
Pedro
|
|
|
|
|