|
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.
|
|
|
|
|
I am faceing a problem when a try to populate datagrid thread rise an exception ...
Object reference not set to an instance of an object.
at System.Windows.Forms.DataGridViewTextBoxCell.PaintPrivate(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, Object formattedValue, String errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts, Boolean computeContentBounds, Boolean computeErrorIconBounds, Boolean paint)
at System.Windows.Forms.DataGridViewTextBoxCell.Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, Object value, Object formattedValue, String errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewCell.PaintWork(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewRow.PaintCells(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewRow.Paint(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow)
at System.Windows.Forms.DataGridView.PaintRows(Graphics g, Rectangle boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.PaintGrid(Graphics g, Rectangle gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
please help
|
|
|
|
|
Can't you trace the code?
|
|
|
|
|
i used try catch in datagrid papulation code but Exciption bypass evry thing and takes me in Main function..
|
|
|
|
|
Please post the code at which point the exception arise and lines above it, so we can have some context to help you.
|
|
|
|
|
Your subject line suggest you're trying to update the DataSource property of a DataGrid control from a background thread you created. If this is true, you cannot do that. You MUST Invoke a method on your form so the UI thread updates the control's DataSource. You cannot manipulate controls from any other thread other than the one that created the control.
|
|
|
|
|