How can I add clock on my VB2010 form? - visual-studio-2010

I wanted to add clock to my form in VB2010. This is what I've tried but it isn't working:
I added Timer control on the form, added Label and add this code on the Timer
Label1.Text = TimeOfDay

Related

Kendo MVC with Inline Editing Default Datetime of DateTime.Now showing page refresh time

I have a Kendo MVC Grid that uses Inline editing. When I click "Add New Record" it is supposed to default the entry to DateTime.Now. The issue is that this value doesn't update, it continues to show the time the page was loaded instead of the time when the row is added.
I have tried to set it in the editor template and the model and I am getting the same result. My guess is I would have to set the javascript but cant find how to do this with inline fields and select the right DateTimePicker to update the value on. How can I have this default value be set when the add new record button is clicked.
When you set the DefaultValue in the DataSource Model definition the DateTime.Now value will get serialized as part of the initialization script.
If you need this to by dynamic you can add an Edit event handler and check if the model instance edited is a newly created one. If so set the date field to the current date and time:
function onEdit(e){
if(e.model.isNew()){
e.model.set("MyDateField",new Date());
}
}
Here is an example.

Don't want to clear records on form

My Access form is for data entry of donations at my church. I don't want the form to clear for each new record. Some of the data will remain the same. Just want to change some fields and select "Add New Record"
Follow these steps :
Go to your form.
Switch to Design view
Select the desired control
Switch to the control's Event tab
In After Update Sleect the ... (3 dots) and choose Code Builder
Change the method to look like this :
Private Sub Name_AfterUpdate()
Me!Name.DefaultValue = """" & Me!Name.Value & """"
End Sub
My control in this code is Name, change that to your control's name
Close the code builder
Done!
You will have to do this for every field you want not to clear!

VB6 _Validation event not firing when tabbing to Cancel button with CausesValidation = False

I have a situation similar to the following simplified description:
A form with a TextBox (call it txtQty) in which a user can enter an integer. The event txtQty_Validate is used to validate the user input and force them to correct any errors before changing focus. This works great with all other controls on the form except for said txtQty. I assume that this is because the Cancel button on the form has the property CausesValidation necessarily set to false; thus when the user Tabs from txtQty to the Cancel button (whose TabIndex is next) it does not appropriately trigger the txtQty_Validation event.
My first instinct was to simply go to the txtQty_KeyPress event (which I am already using to make the RETURN key behave as TAB key) and capture the TAB key and temporarily toggle the CausesValidation property to allow the txtQty_Validation event to fire. However, it seems as though capturing the TAB key is not as easy as I had thought it would be.
Any suggestions? I assume that this cannot be the first time anybody creating a Form has come across such a situation.
Thanks
You could try this in the Cancel GotFocus event.
Dim b As Boolean
Call txtQty_Validate(b)
If b Then txtQty.SetFocus
Assuming you have something like this
Private Sub txtQty_Validate(Cancel As Boolean)
If Not IsNumeric(txtQty.Text) Then
Cancel = True
End If
End Sub

Kendo Grid Edit form - Changing control value programmatically is ignored on submit

I'm using Telerik Kendo UI Professional. I have a grid with an edit template, and several controls on it. I ran into a weird little requirement, where I needed to programmatically set the value of one of the controls, based on another control being changed. The actual change of value seems to happen just fine. However, when I submit the form to save changes, the new, programmatically-set value is ignored; it sends the original value instead. If the user changes the value himself, the new value is submitted just fine.
Here is a sample:
http://dojo.telerik.com/#wittca/otoxO
This is not my original code, but it shows the same problem. In this version, upon opening the edit popup, I programmatically modify the value of the UnitsInStock KendoNumericTextBox. Then when I save the form, I would expect to see the new value, but I still see the old value in the grid. So it does not take the programmatically-generated new value.
My original code is trying to set the value of a KendoComboBox, when one of the other controls changes, and the same situation happens. I didn't have time to create the exact same situation, but most likely if we can fix that dojo sample, the same fix would apply to my ComboBox.
Here is the response I got from Telerik support:
You will need to trigger the change event as well, as the Grid listens for it in order to update the value. Please see the updated example here:
http://dojo.telerik.com/UjUkE
var units = e.container.find("[name='UnitsInStock']").data("kendoNumericTextBox");
units.value( <insert new value here> );
units.trigger("change");
The key line of code is that last one; that manually triggers the "change" event on the control, which forces the Grid to update the value.
This fix also works with my original problem involving ComboBoxes.
He is a solution for you:
If you change the edit function that you have from:
edit: function (e) {
var units = e.container.find("[name='UnitsInStock']").data("kendoNumericTextBox");
var unitsValue = units.value();
units.value(unitsValue+1);
}
to this:
edit: function (e) {
var val = e.model.UnitsInStock;
e.model.set("UnitsInStock", val+ 1);
}
It will bind the updated value for you.
Here is my updated code for you to test:
http://dojo.telerik.com/OHaKA/2

Reset validation messages for date time pickers is not working

I have kendo date time pickers with validations.I want to reset that validation messages on reset button click.When we click on reset button reset the validation messages.I tried that one but it is not working.
This is my reset code
$("#clear").click(function(){
$("#datetimepicker").find("span.k-tooltip-validation").hide();
$("#datetimepicker1").find("span.k-tooltip-validation").hide();
});
MY bin is http://jsbin.com/ufimom/159/edit
You can try this:
$("#datetimepicker span.k-tooltip-validation").hide();
$("#datetimepicker1 span.k-tooltip-validation").hide();
Greetings,

Resources