Thanks, it seems that the problem was I was checking the index when the SelectedIndexChanged was fired. Whenever I made another selection I would receive the error. I switched the code to the Click event and now it works fine.
There is nothing strange if your code does not depend on it.
However, i wrote a code that that register to control's "LostFocus" event and do some job there.
If the user call some other method - i unregister the event handler, but it should be done only after the "LostFocus" occurred.
Because the the user traditionally will call my method in the "Validate" event, you may understand why this behavior raise some problems.
However to overcome it i do the following:
I registered to the "GotFocus" event, and within this event handler i registered to the "LostFocus" event.
When the "LostFocus" event occurred, i do my job and unregistered the handler when it completed.
I have a simple question with no doubt a complex answer. What I am trying to achieve is to check LAN for machines (mostly Workstations but could be windows xxxx Servers among them and find which ones are running a particular Service.
Is there a relatively easy way of doing this? What sort of security measures could get in the way? The service I'll be searching for will does export a remoting interface.
When you design a form in Visual Studio 2005, you may put a control in form and set properties of this control. After you did this, Visual Studio will insert codes to XXX.designer.cs automatically. Even the control is a Third-Part control, Visual Studio can do the same thing.
So, my question is how to do the thing by ourselves ?
You can write the code by yourself.. declare objects and initialize them in InitializeComponent() (run the method in constructor) if you want them to be available at design time or in OnLoad event if you want them to be created at runtime.
vs designer uses *.designer.cs files (and keyword 'partial') to separate it's code from yours. so the file isn't needed.
Is there a way to tell if the Code is running as a Windows App or Web?
Well, if it's running as a web app, then it's running on a server, not on a client. Any UI classes will have a different root. I don't see how this could ever come up, unless you're talking about controls that are hosted in a browser, not ASP.NET code ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
I have a common library that runs in a Windows App and a web app; not controls; I was using pre-compile directives i.e. #if; but that's a bad work around since I have to recompile; I would think that there is a way to know what environment you are running in but I can't find it; I'm thinking about breaking out the code so that I have a Windows version and a Web version; but keeping them in sync is a nightmare.
If your library is called in a web context you should be able to query for the System.Web.HttpContext.Current object. If running as the Windows app this code will throw a NullReferenceException (i.e. there is no HttpContext) so you could put this test in a try / catch block and set your environment based on the results of the test?
Admittedly that's pretty inelegant but I can't think of a better way. Any other suggestions?
Last Visit: 31-Dec-99 19:00 Last Update: 17-Jan-22 7:23