Hello Peter,
I've got the error handling stuff worked out. I finally got email from C1
and they told me which error handler would capture this particular event.
the particular handler that they use, by name, didn't seem to be the right
choice, so I never even tried it.
Anyway, I'm intercepting the exception, displaying my own message, and going
on from there. But I discovered another small issue. Maybe you can shed some
light on it for me.
As I mentioned before, I have textboxes that are bound to various columns in
a table. TB1 goes to Column1, TB2 to Column2, etc. And the Primary key is
Column3. There is a calculation in the table that combines the vales of
Column1 and Column2. If the user enters a value in TB1, then TB2 and the
calculation produces a non-unique value for Column3, the exception is
thrown. The user has a choice from the message box to re-enter the values in
TB1 and TB2, or just cancel the new entry.
Here's the problem. Let's say the user decides to cancel. What I do is call
a Fill on the Connection, which updates the table. This wipes out the new
row the user was tring to add and displays the values from the last row of
data in the textboxes on the form. Or, at least, this is what is supposed to
happen! For some reason, the value in TB2 (the textbox that had focus just
before the exception occured) retains the value the user entered. The table
however does not have this value, only the textbox. All of the other
textboxes are updated correctly with the contents of the current row of the
table. As a quick test, I added a new row, entered a value in TB2 first,
then in TB1 (the values intentionally caused a Primary Key exception). In
this case, the value in TB2 is correct, but the value in TB1 remains
unchanged.
In my error event code, I have even added TB2.Text="" (or any text), but the
value that was typed into the textbox remains, even after the table has been
re-filled. If I use the record navigator to move to the previous record,
then back, the textbox is fine.
This same behavior occurs whether I use a VB.NET textbox or a C1Textbox. Do
you have any idea what might cause this behavior?
Regards,
Lee
""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:J5**************@TK2MSFTNGXA02.phx.gbl...
Hi
I am not familar with the c1FlexGrid.
Basically as a common control in vs.net, e.g. TextBox, it has validate
event which will be raised after the focus is lost. And then we can handle
our validate method in the event handler, e.g. throw an exception or just
pop up a msgbox. I think the c1FlexGrid may use the similar approach,
while
since it pop up a msgbox which is not an exception. If we do not handle an
exception, the exception will be thrown up through the call stack until
the
program crash if we did not handle it in any place in the program. While a
msgbox if just a message, it is similar with the code below.
validate_handle
{
if(notvalid)
msgbox "something is wrong";
}
So in this way we have no idea about that the validate_handle failed.
So the problem depends on how the validate_handle is implemented, e.g.
will it raise another errorevent or something else to give the user a
chance to handle?
Hope this helps.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.