|
I tried this and I thought it did not work. I'l try again.
|
|
|
|
|
I tired this and it did not work. I think I need to add that the property I am trying to hide is not one that I added, but rather one that is available via the control that I inherit. I don't want the user to be able to change the property so I need it hidden.
|
|
|
|
|
You could override the property in your control and then just call the base.property.
Example hiding Label.Text or something similiar:
[Browseable(false)]
public override string Text
{
get{ return base.Text; }
set{ base.Text = value; }
}
This would allow get/setting of the property but it would be not be seen in the property grid.
Later,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
On my MDI Parent Form or SDI Parent Form if I have any control i.e. push button, label etc. When I call my child form those parent controls still there? Anybody knows why, I will be thankful if somebody helps me in that.
Thanks in advance.
|
|
|
|
|
Okay its not a bug if you set your WindowState property to Maximize of Child Form it will behave in a way it required. Finally I found this.
|
|
|
|
|
I have a program that connects to a Web Service to authenticate a user.
When the user clicks ok the program access the Web Service through the
internet.
This actually seems to FREEZE the program until it has finished, how can I
solve this problem?
It's really not a good user interface like now!
I mean maybe I could make like when you are loggin in in MSN Messenger, but
how to do it?
Thankx!
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
What you are seeing is that all the work is being done on one thread, including all the waiting that you have to do while you wait for the webservice to respond.
The solution is to use an Async method or a separate thread. The Async method will use a separate thread but it takes care of all the work for you; while you have to do all the work to use a thread yourself.
If I remember correctly the code that the "Add Web Reference" option generates includes some Async methods. The Async methods begin with Begin and End followed by the name of the method.
Using a method from the CodeProject webservice
ArticleBrief[] GetLatestArticleBrief(int NumArticles);
The Async versions of this method are:
IAsyncResult BeginGetLatestArticleBrief(int NumArticles, AsyncCallback callback, object asyncState); and
ArticleBrief[] EndGetLatestArticleBrief(IAsyncResult asyncResult);
Typical usage is as such
IAsyncResult iar = BeginGetLatestArticleBrief(numArticles, null, null);
if( iar.IsCompleted )
{
articleBriefs = EndGetLatestArticleBrief(iar);
}
else
{
}
Since you wouldn't be doing anything else while the user is logging in I would do this:
IAsyncResult iar = BeginLoginUser(username, password, null, null);
while( !iar.IsCompleted )
{
Application.DoEvents();
}
This is only a brief intro and a limited way of doing things, MSDN contains an entire section on Asynchronous programming which you should read before going much further.
If you use the MSDN that came with VS.NET I found the topic by going to the following nodes: Visual Studio.NET -> .NET Framework -> Programming with the .NET Framework -> Including Asynchronous Calls
HTH,
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
How is late binding done in C#? I'd like to allow for the registration of 'pluggins' (used loosly) for an automation tool for Source Safe. IE as I come across a file type, the appropriate class/library which implements the correct interface is loaded and used to process the file...
|
|
|
|
|
your plugins should implement an interface, which means you don't have to late bind anything beyond checking and casting to the interface.
VB implements its latebinding using reflection behind the scenes (InvokeMember i suppose), which you can do manually in c# if you want.
|
|
|
|
|
But I don't want to have to recompile the code after each time or create a switch/if for each type
ie I don't want to do this
IVSSCheckout itemHandler;
switch (fileExt) {
case "asp":
IVSSCheckout itemHandler = new ASPHandler(); //tight bind is problem
case "cls":
IVSSCheckout itemHandler = new VBFileHandler();
case "cpp":
IVSSCheckout itemHandler = new VCPPPHandler();
}
I would rather do something parallel to:
className = GetFromRegistry( fileExt )
itemHandler = CreateObject( className )
I could very well be missing something quite simple and fundamental as I have just moved into .Net languages from C++ and VB.
|
|
|
|
|
You won't have to if you use an interface.
Here's what you need to do:
1) Write an interface that describes the add-in.
2) Build it to a separate assembly.
3) Reference that assembly both in your main program and in the add-in.
Then it's merely a matter of loading the assembly, finding all the types that implement the interface, creating an instance, and casting it to an interface.
If you look on http://www.gotdotnet.com/team/csharp, you'll find two examples of doing this.
On the information page, there's an "execution time code generation" section that does something nearly identical to what you want to do (from the loading perspective).
On the main page, there's a column on app domains and dynamic loading that does something similar, though it's delegate based instead of interface based.
Hope that helps.
|
|
|
|
|
Thanks a ton... I'll take a look at it those.
|
|
|
|
|
That's great. I knew there would be a way to do it. The reflection namespace was what I was looking for.
I'm not worried about memory resident assemblies as they will be unloaded rather quickly, so loading the Assembly via the Load call appears it will give me what I need. Thanks a lot for your quick responses. And these Reynolds people say you Microsoft guys aren't nice to work with... <sarcasm>
|
|
|
|
|
If you don't have the unload/reload issue, it's a *whole* lot easier to avoid appdomains, put the add-in in the same directory as the exe (or a subdir under it), and just use assembly.Load().
The way appdomains work takes a bit of mind-warping to figure out. It's really like running a process on another machine, from the way you deal with things.
|
|
|
|
|
Eric Gunnerson (msft) wrote:
The way appdomains work takes a bit of mind-warping to figure out.
Hi Eric, i have had my mind warped already (partially)
I understand from your article how to use objects from remote domains in the main app domain, but how does it work the other way around?
Eg. You have main program with an object say A. In my case object A also contains a NetworkStream that should not be disconnected. I want to now load/unload "helper" assmeblies in a remote domain that can reference an instance of object A in the main app. Can this be done, without me landing up in a psychiatric ward?
Reading both parts of the graphing calculator article was already a great help, i cant find any examples on how to do the reverse as described above.
Thanking you in advance
Cheers
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
I think the way you'd do this would be to pass a MarshalByReference object as a parameter to the other app domain when you made a call. That should result in the other app domain having a proxy object to the object in the main app domain.
I haven't tried this, however.
|
|
|
|
|
Really curious why the 'where' statements that the OleDbDataAdaptors creates are excessively wordy...
What are they trying to accomplish here? Do automatic code creators get paid by the line? What is the point of the extra 250 lines of code?
Wouldn't just WHERE (CustomerID=?) work just fine?
this.oleDbDeleteCommand1.CommandText = @"DELETE FROM Customers WHERE (CustomerID = ?) AND (Address = ? OR ? IS NULL AND Address IS NULL) AND (City = ? OR ? IS NULL AND City IS NULL) AND (CompanyName = ?) AND (ContactName = ? OR ? IS NULL AND ContactName IS NULL) AND (ContactTitle = ? OR ? IS NULL AND ContactTitle IS NULL) AND (Country = ? OR ? IS NULL AND Country IS NULL) AND (Fax = ? OR ? IS NULL AND Fax IS NULL) AND (Phone = ? OR ? IS NULL AND Phone IS NULL) AND (PostalCode = ? OR ? IS NULL AND PostalCode IS NULL) AND (Region = ? OR ? IS NULL AND Region IS NULL)";<br />
And the parameter list...
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Address", System.Data.OleDb.OleDbType.VarWChar, 60, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Address", System.Data.DataRowVersion.Original, null));<br />
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Address1", System.Data.OleDb.OleDbType.VarWChar, 60, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Address", System.Data.DataRowVersion.Original, null));<br />
<br />
... x 10 times more
|
|
|
|
|
Ahhh... Optimistic Concurrency. Nevermind.
|
|
|
|
|
Is it possible to create a class, call it a, and make it implicity accept a reasonable cast, for example
string s = MyA;
???
I was thinking of writing a class called ConstString, for example, passing a string into the constructor, and then having it return the string when the object was used as a string. So I could do this
public void MyFunc (ConstString s)
and call it like this
MyFunc(ConstString(myString));
Oh, and if anyone reading has an answer to my XmlTextWriter problem from yesterday, it's still driving me mad.....
Thanks.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
|
|
|
|
|
Christian Graus wrote:
Is it possible to create a class, call it a, and make it implicity accept a reasonable cast, for example
string s = MyA;
???
using System;
class Nish
{
public static void Main()
{
string s = new Nish("Christian Graus");
Console.WriteLine(s);
}
public Nish(string s)
{
m_s = s;
}
public static implicit operator string(Nish a)
{
return a.m_s;
}
private string m_s;
}
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Thanks - looks like I win and C# loses. It's such a shame to find myself fighting the language.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
|
|
|
|
|
You don't need to do that for a string object. strings are immutable so no changes can be made to it.
All methods on string that would do any modification return a new string object containing the changes.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Thanks - I know that, I just wrote the first example that sprang to mind. The object I actually want to pass is an XmlNode, and I dunno that this will help, because once I get back the node, I can still call methods on it that change it.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
|
|
|
|
|
I am trying to use a library file that I created in MFC Visual C++. It
won't let me include it as a reference so I am assuming I need to do
something like this:
[DllImport("MyDLL.dll")]
private static extern bool Counter(out long lpCount);
However I don't just wanna import a method I wanna make an instance of the
class which is called CAppBar. Can anyone point me in the write direction
here? It would be a huge help thanks...
|
|
|
|
|
P/Invoke only lets you hook up to static functions; you can't create C++ instances, as the CLR and C++ rules for how classes work are quite a bit different.
To do this, you'd need to wrap it using the Managed Extensions to C++.
|
|
|
|