|
i just want get the mouse event's name which occur on particular button.
|
|
|
|
|
If your using a event that uses the MouseEventHandler, which passes MouseEventArgs, your able to use the MouseEventArgs to find which button was pressed.
For example:
public Form1()
{
this.MouseDown += new MouseEventHandler(Form1_MouseDown);
}
void Form1_MouseDown(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Middle)
...
}
Use the intellisense to show all of the available MouseButtons to choose from.
|
|
|
|
|
I'm pretty sure Click won't tell you. But you can handle the Up and Down events to detect your own clicks.
private void button1_MouseDown ( object sender , System.Windows.Forms.MouseEventArgs e )
{
switch ( e.Button )
{
case System.Windows.Forms.MouseButtons.Left : ...
}
}
A while back I was writing a class to help me with it, but it's not yet ready for prime time.
|
|
|
|
|
I'm trying to verify if a character is a letter.
Regex.IsMatch("3", "[a-zA-z]") returns TRUE when it should be FALSE.
What am I doing wrong?
thanx
|
|
|
|
|
why not just use the char.IsLetter(char c) function?
|
|
|
|
|
Apart from what Jimmanuel said, your code returns FALSE for me.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
>>> Regex.IsMatch("3", "[a-zA-z]")
false
Works for me. There must be something else wrong with your code.
|
|
|
|
|
Ok, the following code worked for me. I created a Windows Form with a textbox control and a button. Check it out:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (Regex.IsMatch(textBox1.Text, @"[a-zA-z]") == false)
{
MessageBox.Show("false - input is numeric.");
}
else
{
MessageBox.Show("true - input is non-numeric.");
}
}
}
}
hope this helps.
Jay.
foreach( inch on Jason )
{
Girlfriend.IsHappier();
}
|
|
|
|
|
Hi all. I have build a application in C#. I want to create the next cenario. I want to install the application in all the users and in the same time have in the server a "activity monitor" that tells me who is logged in and what's the state of the application. Could some one give me a pointer or two? Help me to find the way of illumination LOL. Thanks every one.
|
|
|
|
|
There is no easy way, you'll have to write the necessary code at the appropriate places and record the info in a database table.
It shouldn't be difficult but may be time consuming.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Heloo,
How can i read a specific txt file and open a new 'mdb' file that will contain some things that the file has.
For instance,
The File contains:
00000 33333 22222 11111
ID=32 Name=Fox DATE=040208
33333 33333 33333 33333
Number=45 Add=LA Cell=12345678
22222 11111 22222 11111
ID=12 Name=LOLA DATE=020207
and so on....
i want to create a new mdb file that will contain a specific columns (ID,NAME,DATE,NUMBER,ADD,CELL)..
i want that the comp will read the file and ignore the numbers(on the first line,on the third line and on the fifth line) and the comp will add a new line for the mdb file(for example: gil.mdb)
it will very help me..
it is for my HUGE project..
thank you very much..
|
|
|
|
|
System.IO.StreamReader sr = new System.IO.StreamReader("c:\\1.txt");
String Line = sr.ReadLine();
And Look for String.Split to split string to array based on entry. And using String.Substring to get specific chars of specific lenght.
You need to manualy create parser to intercept and convert it to your DB writer
|
|
|
|
|
Hello All,
Array.FindAll, Array.Find and List<t>.RemoveAll() are not available in Silverlight. I'm looking for the equivalent Linq expressions of those methods. I'm also finding the equivalent one but it would be great if you guys can share if you already have something. thanks in advance..
|
|
|
|
|
I think it will work.
public static class ArrayHelper {
public static T Find<t>(T[] array,
Predicate<t> match) {
foreach (var o in array) {
if (match(o)) {
return o;
}
}
return default(T);
}
public static T[] FindAll<t>(T[] array,
Predicate<t> match) {
List<t> list = new List<t>();
foreach (var o in array) {
if (match(o)) {
list.Add(o);
}
}
return list.ToArray();
}
}
|
|
|
|
|
I have a custom button class that has some events. so do i need to remove the button events although though I am disposing the button object.
CustomButton b new CustomButton();
Fom1.Controls.Add(b);
b.MyEvent -= MyEventHandler(myEvent);
Fom1.Controls.Remove(b);
b.Dispose();
CustomButton b new CustomButton();
Fom1.Controls.Add(b);
Fom1.Controls.Remove(b);
b.Dispose();
|
|
|
|
|
I would think that disposing the button would remove the connection to the event procedure.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
|
Hi there,
I am writing an application to run on the compact framework.
The application accepts data from a usb barcode scanner and validate the entry against data held on a file read sequentially.
If the barcode data does not match the data on the file I want my user to be able to decide to accept the entry or not, so far so good.
I have a problem with my messagebox.show selection.
The problem is that the messagebox does not display for longer than 1/2 a second or so and code keeps running until the end of the method without stopping.
ps:The carriage return marks the end data input.
Here is the code:
// Textbox to catch the data from the USB scanner
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (e.KeyChar == 13) // Catch carriage return from barcode
{
string scannedData = textBox1.Text.Trim();
this.lblBarCode.Text = scannedData;
if (validate_data(scannedData) == false)
{
this.textBox1.Enabled = false;
DialogResult dlgRes = MessageBox.Show("BarCode data does not match, Accept entry ?",
"Validate BarCode",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1);
if (dlgRes == DialogResult.Yes)
{
// TODO write to output file, don't forget system date !!
}
else
{
// TODO ignore input tidy up
}
}
else
{
// TODO write to output file, don't forget system date !!
}
}
}
catch (Exception z)
{
MessageBox.Show("Error " + z);
}
}
private Boolean validate_data(string scannedData)
{
int i = 0;
string lineData;
lineData = this.lstBoxFiles.SelectedItem.ToString();
i = lineData.IndexOf("-") + 1;
lineData = lineData.Substring(i);
if (lineData != scannedData)
{
return false;
}
else
return true;
}
}
Would any one be so kind as to explain what I am doing wrong.
Thank you
modified on Friday, July 11, 2008 9:55 AM
|
|
|
|
|
Is it the carriage return from the scanner that's invoking the button press on your message box?
If so try setting the e.handled property before showing your message box. Alternatively, most barcode scanners can be programmed to use the tab character instead of the carriage return - in fact that's the normal configuration in my experience. If you can configure it this way you can use the LostFocus event instead with no problems.
Dave
|
|
|
|
|
It is the carriage return invokes yes,
Thanks for your help, will try all this today
Thanks Dave,
modified on Friday, July 11, 2008 9:56 AM
|
|
|
|
|
Hi there,
I could still not make it work.
What I noticed is that if I display a messagebox in my keypress event when I run the code the messagebox displays then disappears without human intervention but the next messagebox does not?
I had to put two messageboxes one after the other in order to achieve my goal.
Pretty ugly I admit. I am missing some fundamental understanding somewhere.
I am running the code on an psion 8515, Compact Framework 3.5, OS windows CE.NET version 5.
Here is the code for anyone interested
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (e.KeyChar == (char)Keys.Return) // Catch carriage return from barcode
{
MessageBox.Show(""); // do not delete. I do not understand why but if we remove this event then the next message box does not stop.
e.Handled = true;
this.lblBarCode.Text = textBox1.Text.Trim();
if (validate_data(lblBarCode.Text) == false)
{
this.textBox1.Enabled = false;
switch(MessageBox.Show(" BarCode does not match, Accept BarCode ?",
"Validate BarCode", MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1))
{
case DialogResult.Yes:
// TODO write to output file, don't forget system date !!
MessageBox.Show("Yes ");
break;
case DialogResult.No:
MessageBox.Show("No ");
// TODO ignore input tidy up
break;
}
}
else
{
// TODO write to output file, don't forget system date !!
}
}
}
catch (Exception z)
{
MessageBox.Show("Error in btnOpenSort_Click" + z);
}
}
private Boolean validate_data(string scannedData)
{
try
{
int i = 0;
string lineData;
lineData = this.lstBoxFiles.SelectedItem.ToString();
i = lineData.IndexOf("-") + 1;
lineData = lineData.Substring(i);
if (lineData != scannedData)
return false;
else
return true;
}
catch (Exception z)
{
MessageBox.Show("Error in validate_data " + z);
return false;
}
}
Thank you,
Scalpabob
modified on Friday, July 11, 2008 9:57 AM
|
|
|
|
|
Sorry for the delay in responding - I've only just checked this thread!
I stripped your code a little so I could just run it on a form with one textbox and it works fine!
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (e.KeyChar == (char)Keys.Return)
{
e.Handled = true;
if (validate_data(textBox1.Text.Trim()) == false)
{
this.textBox1.Enabled = false;
switch (MessageBox.Show(" BarCode does not match, Accept BarCode ?",
"Validate BarCode", MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1))
{
case DialogResult.Yes:
break;
case DialogResult.No:
break;
}
}
}
}
catch (Exception z)
{
MessageBox.Show("Error in btnOpenSort_Click" + z);
}
}
private Boolean validate_data(string scannedData)
{
return false;
}
Have you tested it just inputting data using the keyboard? If it works for you that way you need to look into the configuration codes for the scanner.
Dave
|
|
|
|
|
Thanks for your help.
Indeed it works fine.
|
|
|
|
|
You're welcome
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Hi,
I am reading data from an xml file.
The xml is set up so that there could be line feeds for some of the lines.
When I get these data back in the immediate window I see \n which I believe indicates the carriage return for each line?
How can I get rid of these?
Thanks
"\n use master\n go\n IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[uspGetDomainName]') AND type in (N'P', N'PC'))\n BEGIN\n EXEC dbo.sp_executesql @statement =
...
...
...
|
|
|
|