|
I've already put foreach statement in try/catch block, but that means that if instance property is null i can't examine controls on the form. Imagine yourself using that control, and hopelessly clicking on property expecting UITypeEditor to show up, but nothing happens. And even if instance is not null at that moment and you manage to pick controls, imagine user's face who is using your program when he sees that program is behaving unexpectedly (or does nothing).
I can't use a property that is of MyControl Type, because that way, programmer would be able to pick just one control. And i need that UITypeEditor because programmer should be able to pick an variable number of controls using single property.
Seems like i didn't write original post clearly. Sorry for my bad english.
Thank You, Stewart.
|
|
|
|
|
How often does this actually happen, though, and under what circumstances? I'm sure there probably are instances where it is null , but the documentation doesn't give specifics. The VS.NET designers probably give consistent input while designing. If you're doing this at run-time, you have to make sure that whatever invokes the UITypeEditor provides a proper ITypeDescriptorContext by implementing and using that implementation when invoking the necessary calls.
There just doesn't really seem like any other way to do what you need. The only way to get the instance of your control (or its container, which the ITypeDescriptorContext also has a property for) in UITypeEditor.EditValue is through the ITypeDescriptorContext (or a TypeConverter for that matter). It's the only thing that ties them together.
If your paranoia is getting the best of you (don't worry, it always gets me too), try to evaluate when the Instance or Container properties are null and either avoid those cases or make sure in your implementation that an implementation of that interface is provided (most likely only possible at run-time, since VS.NET and the built-in .NET designers take care of most of the design-time stuff, allowing you to only be a slave to what it provides).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I can't tell when does it happen. I forgot to mention that i was working on control about month or two ago. In my case (with my control and FlashTrackBar from MSDN), i was working for a few days, and then for next few the control didn't work (both design-time and run-time). Sometimes it was changing behaviour even during the use of same instance of VS (same day, of course).
I was really mad about this issue. And disappointed when i saw the explanation in MSDN. After few weeks, i've opened the solution and it just worked. The day after, the same error. And so on, hopelessly.
That means that working on a small project might take years, depending on Framework's will!
Unfortunately, i can see no rule to predict whether Instance is null.
However, seems like i'll have to switch to Delphi, because i've already implemented such control in it. Thank you for you help.
Best wishes,
Filip
|
|
|
|
|
Wait, so you you have a problem with either VS.NET's design-time support or some glitch on your machine and it's the framework's fault? Not hardly. I've written a lot of designer support that's used both in design-time and run-time with no problems - ever! And it works on several hundred machines thus far.
You might try reinstalling VS.NET. Besides, if you're talking about Delphi.NET (Delphi targeting the CLR), then you're still using the framework - it doesn't matter which language you use because it all compiles to IL and uses both the BCL assemblies and any other assemblies you reference. There is no difference, except in a few compiler optimizations for the instructions generated here and there.
So, it's pretty evident that VS.NET is at fault here. Uninstall it, clean up your registry and files, and reinstall it. Something's corrupt.
Or switch do Delphi as you said, but just don't go blaming the framework - even though you're obviously having unfortunate problems - for something that's happening on your machine.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Seems like we misunderstood each other. I SAID that JUST controls which use ITypeDescriptorContext.Instance property were behaving badly. NOT ALL CONTROLS. I could still implement designers without problems, but if i wanted to use instance property i would get those messages. Ok?
At that time i was using framework v1.0 and upgraded to v1.1 (if i still remember). Then i had my OS reinstalled (+VS 2003). And i believe that i would still have the same problem, because MSDN still says that there may be some nulls in this interface. Do you suggest me to try again? (now when i reinstalled everything)?
When i blamed Framework, i didn't mean anything bad, it was more like a joke... sounded funny to me at that moment... I'm not a big fan of MS, but i think they did a good job with framework.
No i was not talking about Delphi .NET, because of reason you wrote. I wrote those controls in Delphi 6, so there's no .NET support.
|
|
|
|
|
I am using the app.config for some purposes that it wasn't meant for, or says microsoft, lol. I used a really great example off of code project that allows me to write back to a app.config file while my project is running. My only problem is, it seems that the assembly holds a copy of the file in memory, and when I write back to it, it doesnt reflect the changes when I read from the file again, it shows me the orginial values. Is there a way to refresh the app.config file after writing to it?
Thanks,
Ryan
|
|
|
|
|
What I know about the app.config file, is that it loads with the AppDomain.
Take a look in the AppDomain documentation to see if you can reload the config file.
Free your mind...
|
|
|
|
|
Once a process is executed in an AppDomain , the configuration information cannot be changed. If you must do this, you must have a process that creates a new AppDomain to run your primary application, which must also exit when the .config file changes. Your host (the launcher) would watch for changes to the .config file and respawn your application after it exits. This is how ASP.NET works, where the host is the ASP.NET worker process (aspnet_wp.exe).
You are right to think that the AppDomain keeps it "cached" (it's actually a one-time read per section, and each section is cached when its read for the first time). The only way to re-read the section is to spawn a new process in a different AppDomain that reads that .config file again.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi Everyone...
DOes anyone know how to do a simple HTTP Text Browser? If you do, can you help me out and email it to me no later than Saturday morning to Guiro565@yahoo.com...Thanx
|
|
|
|
|
Slap a multi-line TextBox in a form with an address bar and a couple buttons, then use the HttpWebRequest and HttpWebResponse (or the WebClient ) from the System.Net namespace. Enabling hyper-linking would be a little more difficult, but not impossible.
Why not just add a WebBrowser control to a form? There's plenty of documentation here on CP and the rest of the 'net (just google). Just drop the Microsoft WebBrowser ActiveX control on a form. A couple of interop assemblies are generated and you now have your own container for the WebBrowser control, just like Internet Explorer (i.e., iexplore.exe). It takes care of everything itself. You can handle events, implement interfaces (sometimes need to create an interop assembly for some interfaces, or define them manually), and walk / change the DOM (reference the Microsoft.mshtml.dll assembly).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Would you happen to have any source code on the above. It will be greatly appreciated!
Guiro
|
|
|
|
|
There's plenty of example code here on CodeProject, and much more on the 'net. Just google for it. CodeProject also has a nice search feature you should use.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is there a way without using COM Interop to enumerate the virtual folders in my system from .Net? My requirement is to build a tree view exactly the same as that of Windows Explorer, with desktop as the root.
|
|
|
|
|
Hi, I hope this is helpful to you. I remember reading about this in the WMI SDK. You can get this information using WMI, which does not use COM, so you should try that. However, I cannot give you any help with the code right now, as I am not at my computer.
|
|
|
|
|
Does anyone know if you can find a closing brace from it's current opening brace in the IDE ?
If you have some deep nesting and the closing brace is off screen it would be nice to find it
quickly based on the opening one.
Thanks in advance.
Rgds,
Ian
|
|
|
|
|
place the cursor either at "{" or "}" and press ctrl+}
|
|
|
|
|
Great tip! Sometimes it's the little things, but I can't tell you how many times I've counted curlies or deleted and reentered one to see its mate bolded for a second (Oops, missed it! One more time.)
Charlie
Here I am. Love me.
|
|
|
|
|
control-]
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
top, works a treat.
thanks !
Rgds,
Ian
|
|
|
|
|
Hello,
does somebody know how I can get the current text-cursor-position (in pixel from the upper left of the window) in a RichTextBox?
Thank You
Bernd
|
|
|
|
|
Use the RichTextBox.SelectionStart property and RichTextBox.GetPositionFromCharIndex method:
int charIndex = richTextBox1.SelectionStart;
Point p = richTextBox1.GetPositionFromCharIndex(charIndex); The point is relative to the control.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hey
I have a Panel Libary class that contains of buttons. Each button has a click event.
I use a panel object in a diffent class named OurMain. When I trigger the butten_click event in the Panel Libary class it should trigger an even in the OurMain class. So far I have oused a hidden Label in each class, so that when a button is pushed, the Label in Panel Libary class gets a different value, The Label in the OurMain class then gets the new value as in the Panel Libary class. In OurMain class the Label has a on Label_TextChanged method, from there I call the different methods I want to trigger in the OurMain class.
This works for most of the time, but not allways .
The question is, is there a better and more safe way of doing this?
Thanks for your help
Thomas
|
|
|
|
|
You could add an event to the Panel class, then have the Panel handle all the Button.Click events, which fires the event you added. Done right, the form containing the panel could access the button (the first parameter in any EventHandler -derived delegate is the object that raised the event). You could even make your own delegate (instead of using the EventHandler delegate) if you don't want to worry about casting:
public delegate void ButtonEventHandler(Button sender, EventArgs e);
public class MyPanel : Panel
{
public MyPanel()
{
button1.Click += new EventHandler(this.button_Click);
button2.Click += new EventHandler(this.button_Click);
}
public event ButtonEventHandler ButtonClick;
private void button_Click(object sender, EventArgs e)
{
if (this.ButtonClick != null)
this.ButtonClick(sender as Button, e);
}
} Then, any button click event is handled by the panel, which then fires it's own event. Note (as I mentioned above), you oculd just stick with the EventHandler delegate for your event, but then your containing Form will have to type-cast the sender each time (making sure that it is a button, of course). Even in the code above, though, your Form should make sure sender isn't null (always better to be safe than sorry).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
and i need to display word docs on my form and handle it.
i can do this with excel docs by adding it's component in the toolbar from com components. but there is no com component for word. and i do not know what is the problem exactly!!!!
Iam using vs.net 2003 profissional and office 2002(xp) and can not use office2003
thnx in advance
|
|
|
|
|
Not sure what you mean by "handle it", but you can host the web browser and navigate a word document there.
RSS feed
|
|
|
|