|
Partial list cannot be sufficiently identified via filename string. Only reasonable option is to try to grab # of files, process, go back and grab another #.
|
|
|
|
|
I have subclassed a Windows Form TextBox control. Inside my subclass I override the OnKeyDown like this:
protected override void OnKeyDown(KeyEventArgs e)
{
// Trap keystrokes here????
}
Shouldn't this have the effect of inhibiting the user from entering any keystrokes, since I don't pass the event up to the parent method? When I execute and type into the texbox, I see my keystrokes.
I am trying to trap keystrokes this way. What am I doing wrong?
Thanks!
Mark
|
|
|
|
|
MarkMokris,
You have misunderstood what this event does. The event is fired when someone types something, it does not stop or change the users input, since you do nothing in the event. If you want to stop users entering info into a textbox, set it to ReadOnly or Disabled.
Regards,
Gareth.
|
|
|
|
|
Thanks.
But then, is there anyway to trap a keystroke before it appears in the textbox? What if I needed to prohibit certain special characters from being typed?
Thanks again!
Mark
|
|
|
|
|
MarkMokris,
If you want to stop certain user input, use regular expressions or in the KeyStroke event, do some checks and remove whatever you dont want. But it would be better to use regular exp.
Regards,
Gareth.
|
|
|
|
|
MarkMokris wrote: since I don't pass the event up to the parent method
That's done automatically (events use multi-cast delegates).
In OnKeyPress, in your
// Trap keystrokes here????
test for particular characters and set e.Handled to true for the ones you want to ignore.
|
|
|
|
|
OnKeyDown is a method that raises the KeyDown event for handlers of that event. You're not stopping keystrokes from showing up because you haven't stopped the processing of the key. You've only stopped the raising of an event.
If you want to stop the keystroke from occuring, inside your custom textbox control, handle the KeyDown event. Inside there, do your processing to figure out if you want the key to be stopped or not and set the e.SuppressKeyPress property to true if you want it stopped.
|
|
|
|
|
Use the Handled property to trap keystrokes on the KeyUp event.
On the KeyPress event you can capture the key that is pressed.
void KeyRecord_KeyUp(Object sender, KeyEventArgs e)
{
e.Handled = true;
}
void KeyRecord_KeyPress(Object sender, KeyPressEventArgs e)
{
e.Handled = true;
MessageBox.Show(e.KeyChar.ToString());
}
I hope this is of some help.
Regards
Guy
P.S. you will also need to set Handled to true in the KeyDown event.
You always pass failure on the way to success.
|
|
|
|
|
Hi,
I am creating an applicatio that creates databases on the date provided.
I have a problem.
I am using datetimepicker for selecting the date.
I need the application to create the database if teh day of the selected date is Thursday only.Otherwise it should show a message box saying "The selecetd day is not Thursday Do you want to continue or not".
How can i do this?
public string GetDatabasename()
{
string namedatabase = dateTimePicker1.Value.ToString("MMdd");
string nameDB = "CustList_PGE_" + namedatabase;
MessageBox.Show("The name of the database will be CustList_PGE_" + namedatabase);
return nameDB;
}
The above mentioed code takes the month and day.
My datetime picker display is like
Thursday February 28,2008
Planning to do it like if in the datetimepicker if its Thursday ,then it will go to a if statement and show the message box.
But my problem is how can i read that it is a thursday from datetime picker.
Thanking You,
|
|
|
|
|
|
Thanks Mike.
I did like this
if (dateTimePicker1.Value.DayOfWeek.ToString().Equals("The selected date is Thursday"))
{
MessageBox.Show("Thursday");
}
else
MessageBox.Show("The selected date is not Thursday,Do you want to continue?", "Options", MessageBoxButtons.YesNo);
}
I have one more doubt;
Is it possible for me to stop the process if i click on "No" in the message box?
If yes How?
Thanking You,
|
|
|
|
|
Read J4amieC's reply, it's important
Trustapple wrote: If yes How?
Read the documentation for MessageBox.Show(), it answers your question.
led mike
|
|
|
|
|
This really is all in the documentation.
The Value property of DatTimePicker returns a DateTime instance which has a DayOfWeek[^] property which is an enumeration
if(myDateTimePicker.Value.DayOfWeek == DayOfWeek.Thursday)<br />
{<br />
}
|
|
|
|
|
J4amieC wrote: This really is all in the documentation.
No!!! Not the documentation!! How cruel of them to put the answers there.
only two letters away from being an asset
|
|
|
|
|
The issue is as follows.
When we click the submit button, the table is built dynamically and is shown in the page. If we chage the font size (Theame resize button from master page)the font size is refreshed but the dynamic table is not seen.
It is using AJAX controls and we think the issue seems to be with AJAX. If we removed the AJAX controls then we are able to see the dynamic table results.
With out AJAX:
To make the dynamic tables work initially, we added a session variable to store the table results during on click and then during preinit we loaded the dynamic table using the session variable. This allowed the font size button to function properly.
With AJAX:
But with AJAX controls the same code dosent seem to respond. We are able to see the table getting loaded in the preinit but the values are not displayed.
Are we missing something here?
Thanks,Arun
|
|
|
|
|
If you are doing a PostBack then you may need to issue a Refresh on the AJAX control to repopulate the data.
|
|
|
|
|
I have a string in which the numbers are entered and decimal point is also allowed. But, when the user enters a string for eg: 123,43 .....even this should be accepted as number and with "," is assumed as period "." , how can i do this.
|
|
|
|
|
use Replace()
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Nothing to do with trimming really, you want to look at String Replace[^]
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
|
for five-digit numbers such as 123,43
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
NumericUpDown, with two decimal places. I would expect the current culture would determine which decimal delimiter is in use (though I've never tried it).
|
|
|
|
|
PIEBALDconsult wrote: I would expect the current culture would determine which decimal delimiter is in use
I trust it does, but the way I understood it the OP wanted both period and comma to act
as decimal point (which I fully understand, the lack of a single international standard way
of using periods and comma's is troublesome).
my point however was the up/down doesn't seem very useful for long numbers: when the increment
corresponds to the last digit, it takes forever to up/down the leading digits; and when it does not,
the last digit(s) are not affected by it.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Yes, but I tend to just type the number into the NumericUpDown anyway.
|
|
|
|
|
I see, I'm still use TextBoxes for that, with some masking if appropriate.
The NUD does a lot of masking (and limit checking) but seems to accept multiple decimal points,
so it may still need validation. And I wish there were a way to hide the up/down arrows...
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|