I am trying to create a winform that will allow me to close when the form either loses focus or deavtivate. When I do Me.Show, it will call the deactivate? Is that right or is weird? The way took it was it fires when it either looses focus or is no longer the active form.
Also it seem like I have to click the form in order for it to work right. I tried Me.focus and that does work the way I expected.
A form has many buttons. One of those buttons contains code to update the TableAdapterManager. One of the many TextBox controls has code in a Validating event handler. There is code to make sure a US phone number is formatted properly.If the user tabs out of the TextBox the Validating code works perfectly and show a message to the user if the phone number is not properly formatted and the focus is place in the offending TextBox.If the user clicks on a button that has code to update the TableAdapterManager the Validating code fires but instead of focus remaining on the offending TextBox, the code in the button Click handler also fires.
I would like to stop the button code from firing.Here is the code for the Validating event of the TextBox:
Private Sub TextBoxPrimaryPhone_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBoxPrimaryPhone.Validating ' Make sure the phone is formatted correctly.
[code]....
What additional coding to I need to include so focus remains on the TextBox?
I am working with Vb.net and have a form with a combo Box. On load the form is loaded with one of the following details depending on what is stored in the database; Cancelled, Processed and Failed.
Then I have an update button and when the user drops down the list he/she can select between Cancelled/Processed/Failed. I want to be able to grey out or disable Processed and Failed, so that when the user updates the field he/she can ONLY update with the Cancelled option ONLY.
We have a VB 2 VB.Net migration MDI application , we have a messagebox in Deactivate event ,once you click Ok for Message Box ,the focus must be set on to the Child Form which is active.
How do you deactivate the ContextMenuStrip when you right click your mouse. Because I have a checkbox that the ContextMenuStrip will not display if it is not check.. If it is check, the ContextMenuStrip will be activate again.
This is a non-MDI windows application. I have a home form containing a panel named Panel1 and two buttons btnForm1 and btnForm2. Clicking btnForm1 and btnForm2 opens up Form1 and Form2 respectively in Panel1. Before a form is opened in Panel1, all opened forms in Panel1 are cleared. The code follows:[code...]
In which events should the above lines be written? In MDI apps this could have been accomplished by including them in Form_Activated and Form_Deactivate events respectively.
But here neither Activated nor Deactivate events fire when you open forms in frmHome.Panel1. Instead of Activated and Deactivate you can use Form_Load an Form_FormClosed events but they will only merge/unmerge menus if existing forms are closed before opening a new form in the panel.
But as I sometimes need forms to be opened and closed keeping existing forms opened, using these events won't fulfill the task. Even the GotFocus and LostFocus events won't work. So I want Activated and Deactivate events to be fired or some other means by which the menus and toolstrips can be merged/unmerged when the form gains/looses focus respectively.
I am already overriding the SnapLines property in my ControlDesigner-derived class to manually forward out various snaplines from the child controls of my control -- the text baseline (pink) snap from the labels and comboboxes; the text inset snap from the labels; the top, bottom, left and right snaplines from the comboboxes. Those snaplines activate when the control itself is moved around on the form and when other controls are moved around it.
What I need is the ability to tell the designer to activate the snaplines and then deactivate them while I'm doing an internal move or resize of the underlying controls.My comboboxes are resizable through overrides of OnMouseDragBegin, OnMouseDragMove, and OnMouseDragEnd in my control designer. The magic bullet I'm looking for is something I can call in Begin to tell the designer to show the snaplines and something in End to tell it to stop.
Allowing people to resize and move the internal controls at design time is kind of useless if they don't show snaplines for each other or for external controls.As with stuff like this, it's incredibly hard to search for. I've found one post on a forum where someone asked this exact question that had (of course) no responses. That's about it.
I'm quite new to vb.net and I was trying to develope something that can activate/deactivate the Optical reader at startup, so I wrote:
[Code]...
but obviously it's not that simple, I read I need registry permission not to have access denied to the specified key, I imported the system.security.permission namespace and I tried some constructors but without any results...anyone can point me to the right procedure?
I've recently run into an unexplainable issue regarding a windows form application I am working on. I've managed to isolate the issue to a single line of code whereby a single TabPage is removed from a TabControl, leaving no tabs left in the TabControl's collection. What happens next is a bit mystifying: my application proceeds to enter a state in which the main form's Activate event is fired subsequently followed by its Deactivate event. As a result, no matter where I click on the form, the application will activate for a split-second then immediately deactivate itself, thereby causing me to be unable to interact with any other GUI controls on the form. I thought maybe another thread is trying to interact with the deleted tab object, but the tab is created and destroyed on the same main gui thread. Does anyone have any insight that may point me in at least a new direction? Stepping through the debugger to the point in code where the tab is removed does not cause any exception to get thrown, so at first glance there doesn't appear to be any coding issues going on (although I would not be surprised that is actually the case!).
For speed, I've decided to use temporary tables as the recordsource for a report. The problem occurs when I try and tidy up after the report is closed by trying to drop the temp table. Trying to do this using database.execute "DROP TABLE x" where x is the name of the temp table. Get a Run-time 3211 error that the table still has locks. I figured that any locks generated by the report would be dropped at least by the Deactivate event, but that doesn't seem to be the case. how to use a temp table in the report withot incurring an enduring table lock? The report is the sole user.
I am using a combo box on a form in vb net 2008. I would like the user to be able to either tab to the control and then select an
item OR the user could click on the combo box and then select the item.
unfortunately it fires twice when the user clicks on the control. This is before any items are selected. I have tried placing it in mouse down , focus , key down etc etc.
It does not fire twice for the enter event so I tried to use that alone, but then there is no dropping down of the combo box when the user clicks on the control. Is there a way to release the combo box enter event on the mouse click event?
I am trying to wait for the webbrowsers page to have finished loading to then carry out the next part of my code.However i am having problems because the DocumentCompleted event fires twice?
I read data into a DS from an XML file. The user has the ability to "Save" or "Save As" at any time. They can also "Open" an existing file or create a "New" one. (brilliant, don't you think?)
I need to make sure I ask the user if they want to save their existing data (i.e. rewrite the XML file) if the DS has changed from the XML load or from the last time they Saved. On Open, New or exit I have been checking the HasChanges function on the DS. This doesn't work the way that I need. I use AcceptChanges throughout the program to commit values to the DS. This appears to kill the HasChanges even though the DS is now different than the XML file.
Is there an event in the DS that fires when data changes? If so, I believe I can set a flag that can be checked later. If not, is there any other way to track that a DS has changed after the initial XML load? Would reloading the XML into a cloned DS and comparing the two work? Seems like a waste of "time", especially with large XML files, but if it's the only way.
I have a class with two descendent classes (child, grandchild):[code]When a property changes in the Measurement class I raise a OnCrucibleOxidizedMassChanged event:[code]However, the OnChanged sub gets called twice, even though I only assign a value to CrucibleOxidizedMass once.
I have a problem with a ComboBox to select FontStyle. I need to select the font style twice to fire the event in SelectedIndexChanged Event, that means for example to click "Arial Black" twice to set the text to this font.
Im parsing through a xml file and a error is thrown and the event is fired off but the exception is still nothing even though it tells me theres an exception.[code]Thats how the code is set up. It is enclosed inside a try statement to catch the error but when the event is raised "ex" is nothing.[code]
In VS2005 I am using click on some elements in a webbrowser document to perform certain functions, eg print or open MS Paint but for some reason all the mouse events fire twice. A second click on the same element might be intentional so I can't just bypass code if the ID is the same as last time. There are no other calls of Document_Click anywhere in the project.[code]I supposes I could stick a timer on it and ignore any within 1s say but cheers for any more elegant solutions.
I have an update statement under RowLeave event of my datagridview. Before I update it I need to validate the cell if there is an empty value. But whenever I moved the focus to another row, RowLeave is called first before CellLeave/CellValidating.Is there another way of validating the cell when leaving a row?
Note: Leaving a cell in the same row is not a problem.
This is just stupid. I've been at this for over 5 hours and can't figure out why my freaking commands aren't firing properly. The only ones that fire properly are the Built-in commands "Edit" & "Cancel"
I am trying to unit test for data being input into a textbox (txtPrice). If it is not numeric, it throws a messagebox stating that the input must be numeric. However, when I unit test, I can't figure out why my test fires the message box twice.THis is my (simple) unit test:
Public Sub txtBoxes_LeaveTest() Dim target As frmEstimate_Accessor = New frmEstimate_Accessor ' TODO: Initialize to an appropriate value Dim sender As Object = Nothing ' TODO: Initialize to an appropriate value[code].....
My understanding is that for unit testing, you declare the sender, and (in this case) set the sender to some value that will trip the message box. 112L should do this on the leave event. I then write my expected, which in this case is 112L, fire the event, and then get the actual out of the text box. I then Assert.AreEqual to ensure the expected and actual are the same.
I want to move a label across the form every X milliseconds. How do I do that? I understand how to use a timer, but don't know how to move the control. Here is my
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label1.Location.X = Label1.Location.X + 10 End Sub "Expression is a value and therefore cannot be the target of an assignment."
Using Visual Studio 2010 / VB.net Windows forms application I have a weird situation occuring. I have a rather simple windows form program I have written where a second form is opened by pressing a button on the "main" form. It is opened simply by the following on the click event:
I've been trying to get a Timer to execute code every 50ms and it's worked okay, but for some reason after doing the code 8 times (i.e. for 400ms) it just stops. As in, won't execute the code any more times. Specifically, it's wired up to an animation (Picture) and a rectangle which moves around the screen (Box). why the timer would suddenly stop executing after doing so for a while? It's the same duration every time.