Click here to Skip to main content
15,905,071 members
Home / Discussions / C#
   

C#

 
AnswerRe: Mouse event Pin
DaveyM6910-Jul-08 8:29
professionalDaveyM6910-Jul-08 8:29 
QuestionRe: Mouse event Pin
zeeShan anSari10-Jul-08 8:34
zeeShan anSari10-Jul-08 8:34 
AnswerRe: Mouse event Pin
TheFM23410-Jul-08 9:48
TheFM23410-Jul-08 9:48 
AnswerRe: Mouse event Pin
PIEBALDconsult10-Jul-08 8:46
mvePIEBALDconsult10-Jul-08 8:46 
QuestionSimple Regex question Pin
kozu10-Jul-08 8:13
kozu10-Jul-08 8:13 
AnswerRe: Simple Regex question Pin
Jimmanuel10-Jul-08 8:26
Jimmanuel10-Jul-08 8:26 
AnswerRe: Simple Regex question Pin
User 665810-Jul-08 8:38
User 665810-Jul-08 8:38 
AnswerRe: Simple Regex question Pin
Daniel Grunwald10-Jul-08 8:44
Daniel Grunwald10-Jul-08 8:44 
AnswerRe: Simple Regex question Pin
jas0n2311-Apr-09 22:39
jas0n2311-Apr-09 22:39 
QuestionCreate a SQL like activity monitor Pin
Kit Fisto10-Jul-08 6:58
Kit Fisto10-Jul-08 6:58 
AnswerRe: Create a SQL like activity monitor Pin
Ashfield10-Jul-08 9:30
Ashfield10-Jul-08 9:30 
QuestionHow to read txt file and open DataBase Pin
Admin88710-Jul-08 6:10
Admin88710-Jul-08 6:10 
AnswerRe: How to read txt file and open DataBase Pin
Saksida Bojan10-Jul-08 8:38
Saksida Bojan10-Jul-08 8:38 
QuestionCan someone help me to find the equivalent Linq expressions? Pin
Michael Sync10-Jul-08 6:04
Michael Sync10-Jul-08 6:04 
AnswerRe: Can someone help me to find the equivalent Linq expressions? Pin
Michael Sync10-Jul-08 16:20
Michael Sync10-Jul-08 16:20 
Questionevents adding and removing Pin
netJP12L10-Jul-08 5:49
netJP12L10-Jul-08 5:49 
AnswerRe: events adding and removing Pin
Thomas Stockwell10-Jul-08 10:35
professionalThomas Stockwell10-Jul-08 10:35 
AnswerRe: events adding and removing Pin
PIEBALDconsult10-Jul-08 11:33
mvePIEBALDconsult10-Jul-08 11:33 
Questionmessagebox does not stop [modified] Pin
scalpabob10-Jul-08 5:47
scalpabob10-Jul-08 5:47 
AnswerRe: message box does not stop Pin
DaveyM6910-Jul-08 8:35
professionalDaveyM6910-Jul-08 8:35 
GeneralRe: messagebox does not stop [modified] Pin
scalpabob10-Jul-08 20:36
scalpabob10-Jul-08 20:36 
GeneralRe: messagebox does not stop [modified] Pin
scalpabob11-Jul-08 3:38
scalpabob11-Jul-08 3:38 
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

GeneralRe: messagebox does not stop Pin
DaveyM6914-Jul-08 12:20
professionalDaveyM6914-Jul-08 12:20 
GeneralRe: messagebox does not stop Pin
scalpabob17-Aug-08 22:16
scalpabob17-Aug-08 22:16 
GeneralRe: messagebox does not stop Pin
DaveyM6918-Aug-08 8:11
professionalDaveyM6918-Aug-08 8:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.