|
|
Hi all,
I have a textbox with autocomplete set to suggest.
I want to execute my code in the Textbox_KeyDown event on the enter key,
but enter key is also invoked when I select an item from the text box autocomplete items.
That is not what I want.
I want the selected item in the textbox and then execute my code.
code:
private void opdrverwTextbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == (Keys.Enter) && !string.IsNullOrEmpty(opdrverwTextbox.Text))
{
e.Handled = true;
a lot of other code........;
}
opdrverwTextbox.Clear();
opdrverwTextbox.Visible = false;
opdrverwLabel.Visible = false;
dataGridView_Update();
}
}
I don't want to set autocomplete to suggest-append.
is there a workaround for this?
Merry Christmas,
Groover
b>
0200 A9 23
0202 8D 01 80
0205 00
|
|
|
|
|
Hi all,
Found a solution myself after long google search.
It works but can someone explain how?
here is my new code:
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern short GetKeyState(Keys key);
private void opdrverwTextbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == (Keys.Enter) && !string.IsNullOrEmpty(opdrverwTextbox.Text)&&
GetKeyState(Keys.Enter) < 0)
{
e.Handled = true;
a lot of other code........;
}
opdrverwTextbox.Clear();
opdrverwTextbox.Visible = false;
opdrverwLabel.Visible = false;
dataGridView_Update();
}
Groover,
0200 A9 23
0202 8D 01 80
0205 00
|
|
|
|
|
I am developing an c# application and
it uses many .net assemblies. For some
reason i need to move a dll to program
files folder and that dll depends on
many other assembly present in the
application folder and this makes me to copy all dependent dlls to programfiles
folder. This will cause duplication of dll
in both application and programfiles
directory. I know that moving
dependent assembly to GAC will resolve
this issue but i shound not put many assembly in GAC. So please suggest a
way to make .Net dll to reference its
dependent dlls.
|
|
|
|
|
KASR1 wrote: For some reason i need to move a dll to program files folder
No there is no reason you need to do that.
Just as many other programs do not. What they do is create a sub folder and that is where the application goes.
|
|
|
|
|
I am not sure whether i have confused.
Lets put that again, during deployment of my application i need install a particular dll to program files sub directory (eg. C:\program files\test). But my application will be in different directory. Since the dll Installed away from application directory and it uses/references many dlls present in application directory. How do i make that dll to pick dependent dlls from application directory. I dont want to move to GAC. Hope its clear.
|
|
|
|
|
Your application, let us call in it MyApp.exe will live in the following directly.
C:\program files\MyCompany
The dependent dlls will live in the same directory.
|
|
|
|
|
Lets us take an eg., I have MyApp.exe, Test1.dll,Test2.dll,Test3.dll.
MyApp.exe depends/uses Test1.dll
Test1.dll depends/uses Test2.dll, Test3.dll
If i am installing all binaries to same directory say D:\TestAppln\ then my application will work perfectly.
But due to some issues i need to move Test1.dll to programfiles sub-directory always(e.g, C:\program files\MyCompany) irrespective of installation. My application may reside in any directory.
Since Test1.dll depends on Test2.dll and Test3.dll, i need to copy them from application folder to Test1.dll's folder i'e (e.g, C:\program files\MyCompany). Otherwise Test1.dll will not load.
So my question is how to make Test1.dll to refer its dependant dll from application folder.
I am looking for options other than GAC.
|
|
|
|
|
You can load the dlls dynamically.
Also the AppDomain has an option that allows you to specify a search path.
Creating an AppDomain yourself is one option. However I believe it is also possible to set that in the application itself perhaps via one of the properties.
|
|
|
|
|
Your question is pretty unclear. In a normal .net application you add references to .net assembly. So it has to exist in a location known to the application. If you don't wish to do this you can go the MEF (Managed Extensibility Framework) way. Have a look at these links - MEF in .Net[^]
Cheers,
Karthik
|
|
|
|
|
I am not sure whether i have confused.
Lets put that again, during deployment of my application i need install a particular dll to program files sub directory (eg. C:\program files\test). But my application will be in different directory. Since the dll Installed away from application directory and it uses/references many dlls present in application directory. How do i make that dll to pick dependent dlls from application directory. I dont want to move to GAC. Hope its clear.
|
|
|
|
|
Yes this is possible, for strongly named assemblies, with an addition to the configuration section of the application's configuration file ( appname.exe.config ).
In this example we have an assembly StealthLib.dll which has been moved out of the applications's base directory to v:\Temp . Information about this new location is given in the dependentAssembly element where we must specify the assemblyIdentity and the codeBase .
="1.0"="utf-8"
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="StealthLib" publicKeyToken="e0505f3b3553d5af"/>
<codeBase version="1.0.0.0" href="file://v:/Temp/StealthLib.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Be really careful when editing the configuration file as errors are silently ignored. For example the assembly will not be found if the casing of publicKeyToken is changed to PublicKeyToken.
The Assembly Binding Log Viewer (FUSLOGVW.exe) which comes with the .NET SDK is very useful for resolving assembly loading problems as it will log all the locations that have been searched for dependent assemblies.
LOG: Appbase = file:LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MainProg.exe
Calling assembly : MainProg, Version=1.0.4743.26012, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\VC\Projects\CP\AssemblyProbing\MainProg\bin\Debug\MainProg.exe.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: StealthLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e0505f3b3553d5af
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:LOG: Assembly download was successful. Attempting setup of file: v:\Temp\StealthLib.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: StealthLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e0505f3b3553d5af
LOG: Binding succeeds. Returns assembly from v:\Temp\StealthLib.dll.
LOG: Assembly is loaded in default load context.
Good luck
Alan.
|
|
|
|
|
Oh really great!. your input much appreciated. I have another question, Can we use the configfile for a dll to locate its dependent assembly? Or its only applicable for exe?
|
|
|
|
|
That's an interesting question that I don't know the answer to. Why not try it out? I may look at it tomorrow and if I do I'll post another reply.
Alan.
|
|
|
|
|
Did you get any update on this?
|
|
|
|
|
If you have say App.exe -> DllA -> DllB, i.e. DllA uses DllB and App does not directly reference DllB. If DllA and DllB have been moved out of the application base directory then App.exe.config must be edited to provide separate location information for both DllA and DllB and there is no assumption that DllB now resides in the same place as DllA.
Think of it like this: There is one process and the code in DllA executes in the context of that process. When code in DllA needs to call code residing in DllB then that assembly is loaded by 'the process' whose default locations are the GAC and the application base directory. Overrides to this default behaviour are on a per assembly basis.
Any information contained within *.dll.config is not read automatically and will be ignored.
Alan.
modified 2-Jan-13 17:27pm.
|
|
|
|
|
Thanks for the update. Immm... Need to find a way.
|
|
|
|
|
KASR1 wrote: i shound not put many assembly in GAC
Why not?
|
|
|
|
|
Even i am concerned about that, but i was asked to find other possible options to make the dll to refer its dependent dlls. I am interested to know whether it can be achieved via config file.
|
|
|
|
|
Hi, I want to get the latitude and longitude for a given address using google apis. Is it possible to do this in the windows based application?If possible how to do this?
|
|
|
|
|
I haven't used it before but here is a link [^] To the api.
Frazzle the name say's it all
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
John F. Woods
|
|
|
|
|
I think google earth api can be used in .NET applications.You have to embed the required javascript functions in the HTML behind
a webBrowser object and then call the functions using the
webBrowser.Document.InvokeScript method.
|
|
|
|
|
Hi
I am in the process of developing a cloud backup software. The application is a desktop application developed using C#.
I need to add an option to stop/pause the backup if the computer was connected to a 3G network to save cost for the user.
I cannot seem to be able to find any example on how this can be achieved, there are some examples for Windows Phone and Windows Store Apps but I cannot find anything that can check if the connection type is a WiFi/Ethernet or 3G the latter is my main concern.
I tried a test application to enumerate the networks:
Console.WriteLine("checking network interfaces\n");
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (var networkInterface in interfaces)
{
Console.WriteLine("Interface Detected");
Console.WriteLine("Description: "+networkInterface.Description);
Console.WriteLine("ID: " + networkInterface.Id);
Console.WriteLine("Name: " + networkInterface.Name);
Console.WriteLine("Interface Type: " + networkInterface.NetworkInterfaceType);
Console.WriteLine("Operational Status: " + networkInterface.OperationalStatus.ToString());
Console.WriteLine("Speed: " + networkInterface.Speed.ToString());
Console.WriteLine("Supports Multicast: " + networkInterface.SupportsMulticast.ToString());
Console.WriteLine("#########################################################\n");
}
The above code list my 3G connection as PPP which can be either ADSL or 3G. I am not sure if I can differentiate using some other options or APIs
I need a clear way to distinguish between those networks and so far I cannot find a way of doing so.
Can someone please help?
modified 24-Dec-12 7:12am.
|
|
|
|
|
|
Thats for Windows Phone, sadly the solution does not work with desktop applications.
|
|
|
|