|
I am a student working on a stanalone project.
I have problem making a double click event on button. Is it that c# cannot do it? Have to use multi language like include a VBscript? If yes how to use multi language? Can i see a executable source code cause i m quite a slow learner.
Example: how to make a window based application that if u double left click your button. The label will be labeled "Hi", and if u single left click the button it will display "Hello".
It is a simple example i give to lower complicate my question. I have already spend quite some time developing my other functions in c# and got stuck to this problem therefore i wish not to change my programming language but import some other language to my c# project if necessary.
Please help fast... deadline coming near...
|
|
|
|
|
You don't have to use any other language here.
You'll have to handle the Click event of your button and determine inside the event handler whether two consecutive clicks are close enough to be considered a double click. To achieve this, start a simple timer in the event handler and check whether its interval has elapsed. If not, the user double-clicked your button.
www.troschuetz.de
|
|
|
|
|
Stefan Troschütz wrote:
To achieve this, start a simple timer in the event handler and check whether its interval has elapsed
This is an old VB trick, and is more or less obsolete with .NET
An easier way is to handle the MouseDown event on your button, which raises an event with MouseEventArgs which in turn has a Clicks property. Here is some simple code to demonstrate:
private void button2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Console.WriteLine(e.Clicks);
}
If you associate this with a button (in my case it was named button2), run the project in debug mode, and click the button while watching your Output window you should see a list of 1's & 2's coming up based on the number of clicks recieved on the button. So your code should read along the lines of
if(e.Clicks == 1)
else
HTH
|
|
|
|
|
|
Sorry, me very beginner...
How to do that?
|
|
|
|
|
|
Thanks guys for the advices. It have help me a lot.
|
|
|
|
|
Following is a sample of a C# class I created for one of my software projects.
I use it to register my application in the shortcut menu (right-click menu) of
all the files and folders of the HDD. I chose a simple registry approach to
this problem beacause I find it much easier than buiding and registering a COM
object (and I must say I'n not really into COM programming right now, so it
will be kinda hard for me to learn now, having to finish my project a.s.a.p.).
Basicly, the Associate function takes three parameters, the name of the
extension, the desired text to display and the path to the .exe file. (EG. If I
need to register DoIt that is located at C:\DoIt.exe and display the text DoIt
in the menu i use Associate("DoIt", "&DoIt", "C:\DoIt.exe") ). It works by
going to HKEY_CLASSES_ROOT in the registry and opening/creating the
AllFileSystemObjects subkey, whitch handles all the files and folders. It then
creates three new subkeys in this order shell \ extensionName \ command and
registers the .exe so that it is displayed in the right-click menu.
Everything works well, but I still have a problem. I need the path of the file
or folder on whitch I right-click to be sent as a parameter to my main
application (same as using command-line parameters) and I do this by adding %1
after my application's path in the registry (line 26 of the class). However,
this works only if I have a single file or folder selected and I was wondering
if it is possible to use this method to send multiple paths as parameters to my
application (by selecting multiple files or folders or both).
I would really appreciate your help beacause I'm... well, stuck. 10x a lot.
P.S. Please don't hate me for the long description or for the almost childish
manner that I used to express it, but I wanted my problem thoroughly
understood. No offence meant.
using System;
using Microsoft.Win32;
namespace ShellExtension
{
public class ShellExtension
{
public ShellExtension() { }
public void Associate(string extensionName, string extensionText, string filePath)
{
RegistryKey ClassesRoot = Registry.ClassesRoot;
RegistryKey AllFileSystemObjects = ClassesRoot.OpenSubKey("AllFileSystemObjects", true);
if (AllFileSystemObjects != null)
{
RegistryKey shell = AllFileSystemObjects.OpenSubKey("shell", true);
if (shell != null)
{
shell.SetValue("", extensionName);
shell.CreateSubKey(extensionName);
RegistryKey shell_1 = shell.OpenSubKey(extensionName, true);
shell_1.SetValue("", extensionText);
shell_1.CreateSubKey("command");
RegistryKey shell_2 = shell_1.OpenSubKey("command", true);
shell_2.SetValue("", "\"" + filePath + "\" \"%1\"");
return;
}
else
{
AllFileSystemObjects.CreateSubKey("shell");
this.Associate(extensionName, extensionText, filePath);
return;
}
}
else
{
ClassesRoot.CreateSubKey("AllFileSystemObjects");
this.Associate(extensionName, extensionText, filePath);
return;
}
}
public void unAssociate(string extensionName)
{
RegistryKey ClassesRoot = Registry.ClassesRoot;
RegistryKey AllFileSystemObjects = ClassesRoot.OpenSubKey("AllFileSystemObjects", true);
RegistryKey shell = AllFileSystemObjects.OpenSubKey("shell", true);
if (shell.OpenSubKey(extensionName) != null)
{
shell.DeleteSubKeyTree(extensionName);
}
return;
}
}
}
Born from the dark, in the black cloak of night.
|
|
|
|
|
when i write the date in win.txt
it was like this
Lsbox_Date.Items.Add(DTP_Today.Value.ToShortDateString());
so if the regional setting was set to MM/dd/yyyy it will write the date the same as regional setting
so i change it to this which always gonna be dd/mm/yyyy
Lsbox_Date.Items.Add(DTP_Today.Value.Day.ToString()+
"/"+DTP_Today.Value.Month.ToString()+"/"+DTP_Today.Value.Year.ToString());
when i read the win.txt
this code is reading the date from win.txt
StreamReader Read_key = File.OpenText(@windir+"\\Win.txt");
string key_Trim;
string key;
key_Trim = Read_key.ReadLine();
key = key_Trim.TrimEnd();
Read_key.Close();
Convert the key to datetime
DTP_Key.Value = Convert.ToDateTime(key.ToString());
so if the regional setting is set to dd/mm/yyyy i have no Problem coz the format is the same
but if the regional setting is set to mm/dd/yyyy then i get an error converting the key string.
i need help pls ASAP
|
|
|
|
|
Use a explicit CultureInfo for writing and reading the date to be independent from setting of the PC:
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US");
DTP_Today.Value.ToString("d", culture);
Convert.ToDateTime(key.ToString(), culture);
www.troschuetz.de
|
|
|
|
|
is it possible to have two assemblies having same attributes.
please let me know if there are any good documents for this.
|
|
|
|
|
I'm not sure that I understand what you're trying to accomplish here, but... As far as I know, the only requirement for an assembly to live in the GAC is that it has a unique strong name. Google will yield plenty of results, if you search, but there are a couple of links to get you started:- An entry[^] on the GAC from Prabhu Ram Prasath's blog
- Jan Seda's article[^] here on CodeProject.
Hope that helps.
--Jesse
|
|
|
|
|
Hey too good articles.............
solved too many doubts I had.............
Prabhu Ram Prasath's dothis guy have some more aricles on anything like this......
And as I am sending u the reply I have one more question......
How does reflection helps GAC and Also WebServices, Bcoz I have seen so many exmples where people use refletions to call web service methods. I dont what might be the exact reason.
Regards,
|
|
|
|
|
IamADotNetGuy wrote:
Prabhu Ram Prasath's dothis guy have some more aricles on anything like this
I honestly don't know. I found that article when I ran a quick google while answering your post.
IamADotNetGuy wrote:
How does reflection helps GAC and Also WebServices
There have been tons of things written on reflection in .NET. If you're truly interested, I'd encourage you to search the articles here on CodeProject and google the topic. They'll do a better job of covering the topic then I can in a reply. In my experience the most common use for reflection is to enable late binding of an object. Again, if you're not familiar with late binding and would like more information, I'd encourage you to google it. Here[^] is an MSDN article to get you started.
Hope that helps.
--Jesse
|
|
|
|
|
As we know we can pass the parameters by ref and also by val.
Sometimes we will pass object as reference type even though they are already reference type.
Please feel free to say dont be stupid
|
|
|
|
|
You need to pass an object by ref, if the method you're passing it to will replace it with another object.
This example is useless, but it shows the effect:
<br />
private void DummyReplaceTwoStrings(String s1, String s2){<br />
s1 = "first text";<br />
s2 = "second text";<br />
}<br />
<br />
private void ReplaceTwoStrings(ref String s1, ref String s2){<br />
s1 = "first text";<br />
s2 = "second text";<br />
}<br />
<br />
private void CallerMethod(){<br />
String s1 = "hello";<br />
String s2 = "world";<br />
<br />
DummyReplaceTwoStrings(s1, s2);<br />
Console.WriteLine(s1);<br />
Console.WriteLine(s2);<br />
<br />
ReplaceTwoStrings(ref s1, ref s2);<br />
Console.WriteLine(s1);<br />
Console.WriteLine(s2);<br />
}<br />
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
|
Better now?
You've won a personal extra-ref: r e f
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
Hi,
I am trying to open a word document.It creates a application instance (winword.exe) but fails to open ,instead gets hanged.
when I try to kill the process it says access denied.
please help
Sukanya
|
|
|
|
|
It's impossible to tell you want your doing wrong when you haven't posted a code snippet showing how you're launching Word.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Some (or many?) of the useful Windows APIs have not made it yet to the .NET FCL. For example I was searching for the NetServerEnum() API equivalent functionality in FCl but could not find it. Had to do interop and call the API…
In general what is the policy on the relation and availability of Win32 APIs and .NET FCL? Will all the APIs be available with .NET FCL in future? What were the criteria to include some of the APIs in current version of the FCL and exclude some?
Salil Khedkar [^]
|
|
|
|
|
Hi folks!
I am trying to convert EBCDIC file to ASCII file. the issues are
1) Can all EBCDIC file be converted to ASCII without loss of information.(There is one character cent sign which is not in ASCII, how to handle that?)
2)What about non printable characters in EBCDIC, do they all converted to ASCII format?
Suggest some way.
Thanks n Regards
Ranjan
|
|
|
|
|
I have a picture box which is 48x48 in size and I want to set the image at runtime using a System.Drawing.Icon object which I have previously loaded.
I wish to know how I can display the icon in the picture box so the quality and resolution is the same as if I selected an icon file in design time and assigned this to the PictureBox.
At present I am converting the icon object to a bitmap (iconObject.ToBitmap()) and using this to populate the PictureBox. However this results is a grainy/poor quality image appearing in the picture box.
If I set the image property of the PictureBox at design time by selecting an icon file (*.ico) the image displayed is very crisp and clean and is at the highest resolution the icon supports.
I guess that I need to do some sort of image conversion from the icon object to some sort of high resolution image object. The .ToBitmap() method in the Icon object is obviously not sufficient.
Can anyone help please?
Can you tell me how I should be assigning icons to the image property so they are displayed at the high resolution I get when doing it in design time?
Ben
|
|
|
|
|
I use windows media encoder SDK to insert Mark In and Mark Out. But it will cut the selected part to be a new file.
I want to just insert markers without cutting. Can it be done?
Please help
|
|
|
|
|
In my application, the majority of data is taken not from a database, but is generated by the application itself.
Now before report generation I have to spread these data across tables for the sake of a single report.
It's too inconvenient.
Is there a way to do it directly, or, ideally, visually?
|
|
|
|