VB.net Application wide Copy and paste (Text) - vb.net

Im trying to implement application wide copy and paste short cuts. (ctrl+C) etc.
The application consists of forms drawn in tab pages, and there are quite alot of forms. Ideally im after something (in the keypress of the main form) that would just see if the active control is a text box and If so pastes or copies text. Doing so on every text box on every form is unfeasible.
Another approach i guess would be to override the text box control application wide?
There must be an easy way to do this surely.
My googling so far hasn't come up with anything. Thankyou.

Ok; turns out there was a simple problem preventing this from working.
The EDIT menu in the menu bar on the main parent form was 'consuming' these keyboard short cuts.
Deleting this menu fixed the issue instantly.

Related

in Access, Bound Combo Boxes do not update unless the form is already Dirty

I'm working on a fairly complex Access Database, trying to build forms with custom buttons for working with records. I'm using list boxes to display and navigate through records and all fields for existing records are disabled unless the user presses an edit button. The problem I'm having is that if I press the Edit or Add New button, enabling all of the fields, and then try to change the selection in a combo box, it does not update on the first try.
If I edit a text box first then the combo boxes work fine.
I've determined that the control's beforeUpdate and afterUpdate events are not firing on the first try but the action triggers the form_Dirty event and then it works as expected. I tried setting Me.Dirty = True with the Edit button and that solved the problem but it causes problems with some of my other code and it seems like an unnecessary workaround if only I understood the actual cause of the problem. It also works as expected if I leave the Combo Box unbound, but I am trying to build a template that doesn't require too much work to build new forms off of and I would rather not go that route.
It must have something to do with some bit of code I'm using because I can start a basic form and the combo boxes work fine.
I've started a basic test form and am adding code from my template form bit by bit until the problem arises, but it's a tedious process. Any help would be appreciated.
What am I missing? Is there some way of getting the Combo Box events to fire before the form is dirty?
UPDATE:
I have templates for a basic form, a form with a single subform, and a form with multiple subs in a tab control.
After some more testing I discovered that this problem does not apply to the basic form which has no subforms. This template uses similar code to the others for new, edit, cancel, save and delete buttons and for preventing accidental changes, preventing Form_unload during an edit and so on. The main difference I can think of off the top of my head is that the templates with subforms use class modules and collections to hold various data and pass it between the main form and subforms. Not sure if or how this might relate to combo box functionality.
I built most of this last winter then got too busy over the summer to work on it. Just now picking it up again and I'm having to re-learn a lot of the details of how my code works.
you can try to use Me.CboName.Requery in your After Update event.
I figured it out. I was calling a procedure with a form refresh in it from the Form_Dirty event and for whatever reason the refresh at exactly the wrong time was causing the combo box Before_Update and After_Update events to be skipped and the combo box value to not change. It was also causing text entered into a textbox to overwrite existing text on the first keystroke.

Word 2010 ActiveX control forms - formatting issues

Hopefully a quick one
I am creating a form in Word with a Save macro that uses an ActiveX Label as a button. The label works fine as a button but I am having 2 issues:
when using the document in normal mode, the coding text in curly brackets for the label is still visible - see image
How do I get rid of this?
When printing the form, the button pushes the header text down a line:
You can see in the first picture that there is no gap here.
Thanks for your help.
(1) Press Alt+F9 to toggle off display of field codes (and make sure you're not in Design Mode).
(2) is impossible to be sure without having the document in front of me but...
Printing problems are notorious with ActiveX controls, which were designed for use with UserForms, not for the document surface. Your best bet for stability would be to use a one-row, two-column table with the button on the left and the address on the right.
Or use a MacroButton field code instead of an ActiveX control.

Cannot edit cells after touching combobox - I think i've encountered a bug

So here i was building a form in excel for work ya, and to make it easy on the eyes and fool proof i removed 90% of the UI. On that form i put some activex combo boxes. Everything was perfect, and then i tried to edit a cell after i entered in the data in that combo box, but low to my woes i couldnt.
It seemed that touching the combo box locked every other cell in the form. Flabbergasted i did some experimenting and found a way to isolate the issue. Thus i created a test environment for the error(doc linked below). When the UI is removed clicking the combobox locks all other cells. But when the UI is there, no issue happens. Furthermore it seems the formula bar being disabled is the cause.
Is this a bug, a programming error, or something else. I'm at a total lost and would appreciate any help.
My test File, for those how want to try it
When in edit mode shift+esc to hide UI, when hidden hold shift+ctrl then type edit to bring back UI.

Tab between Excel worksheet cells and form controls

I have a worksheet in Excel 2010 that is protected and used as a form for user-fillable values. The form contains 80 cells to be filled in and two radio button form controls to be selected. The form consists of two pages on the worksheet that are placed side by side horizontally (horizontally is a better user experience than vertically in this situation).
To get tabbing to go through the cells on the first page and then on the second page in the desired order, I used the solution on page 4 of the thread at "http://answers.microsoft.com/en-us/office/forum/office_2007-excel/establishing-enter-order-on-a-protected-sheet/e7a223f3-2dae-4c7b-a37f-1819c68be5dc". This works excellently for regular cells.
The problem is how can I also tab to the radio buttons, which are located about a third of the way through the desired tab sequence? Unfortunately, it's not as easy as just adding the radio button names to the TabOrder array mentioned in the thread.
I've found various threads talking about tabbing between controls, but nothing that solves tabbing from regular cells to form controls, between the form controls, and then back to regular cells.
I'm relatively new to Excel VBA programming and could really use your help. :-)
Thanks!
Don
I can't add a comment, so I have to put this in the answer section even though it is not really an answer: Not sure if this is still an issue for you, but are you using Option Buttons or a Group Box. And are you using Form Controls or ActiveX.
The only thing that I have found that may help is to tab to the group itself, then use the arrow keys: "When you tab to the group, you can use the arrow keys to select the next/previous option." and "2. You can set an accelerator key on each one by adding an ampersand (&) before one letter in the label. For example, if the label's caption is "&Next", it will appear as "Next", and Alt-N will be the keystroke that selects that option. Be careful not to choose a keystroke that opens a menu -- for example, don't pick F, because Alt-F almost alway opens the File menu."
From: http://www.mrexcel.com/forum/microsoft-access/557082-how-idiotic-no-way-tab-stop-option-button-within-group.html

Very slow design view on a complex form with a lot of controls

Let's start with a confession: I came from a VB6 background, and I'm accustomed to coding within the events of objects on a form, and as such my code for events ends up in somewhat random order in the code window. With this habit, it's never been very important to remember the names of controls (although I name them well)... I just double click on a button in the design view, which brings me straight to the code for that control's primary event. If I forget the name of a control, I click it and view properties. It's not a habit I've moved away from.
Well, now this is catching up to me. Using VS Express 2013, I have a form that contains a HUGE number of containers-within-containers, labels, buttons, and other doohickeys. I ported my code from VS.NET Express 2008 where this wasn't a problem. But now the act of selecting any control in the design view takes around 10 seconds before I can view its properties. If I drag to resize a control, and another 10 seconds passes before I can select another control. It makes designing this form nearly impractical.
In this particular project, I'm using use a tab control (which is never visible to the user) to design many "screens" which each contain panels full of controls. The panels for each "screen" are moved out of the tabs and docked into the main form as requested by the user changing screens. (I'm using the term "screen" to mean a window full of controls, usually maximized.)
Within the same project, a simple modal password-change form isn't slow to edit controls visually, even if the complex form is still visible in the IDE.
My question is in three parts:
First, what the heck is it spending all that time doing?
Second, is there a setting I can tweak to improve the speed?
Third, should I give up on trying to speed it up as-is, and move each "screen" into its own form for design purposes to avoid this slowness? (It's a lot of work to do that now... see next paragraph.)
Thus far I have avoided separating "screens" onto separate forms because I don't want a new window to come up when users change screens, and because code for the controls in one screen may affect the properties of controls on other screens... In such cases I prefer not to write out
form.doohickey.text = "blah"
..but rather keep it as ...
doohickey.text = "blah"
I'm using VB but I don't think this question is VB-specific.)
First off, I feel your pain. I have a management section of the application that I'm writing and I'm using a TabControl as well. I have 10 tabs so far and I've only added controls to about 4-5 tabs. I just added up the controls I have and there are about 360 controls so far on this one form and the designer file is ~3300 lines long. Currently anytime I change a property value of one of the controls or go to save the Designer, it takes about 3-4 seconds each time. I have a fairly decent machine; i5-3320M, 8GB RAM, intel 330 SSD, and it still takes a bit for it to do things within the tabControl. It also takes FOREVER to open and load the designer on that form...
What I've found is that it is easier to open a new instance of Visual Studio, create a test application, add a TabControl with the same properties, and design a new tab page from there. When I'm done I do a copy-paste into my actual project. This works great except for the few custom controls I've written in my main application project, I just have to sit and wait while adding them.
I'm now answering my own question. This is the approach I've ended up using, and it helps a lot...
My overall goal was to have an interface that didn't present a lot of windows, but still presented many different "screens".
I used to place all the different controls of different "screens" on separate panels, which were each contained in separate tabs of an invisible TabControl. I would then move those panels to my main form as needed by changing their Parent property of each panel as needed. The only problem with this is that the Winforms designer got ridiculously slow as the number of controls on a form increased into the hundreds.
Now, I am now designing each "screen" as a separate form, each of which contains a panel whose Dock property = Fill. Such a panel contains everything else on the form. The form itself never becomes visible.
As needed for to view various screens, I execute:
ScreenForm.Panel1.Parent = Mainform
...or, depending on how I lay it out...
ScreenForm.Panel1.Parent = Mainform.PanelXYZ
...I also either unload or hide any panels which already exist in the panel's new container.
I was GLADLY SURPRISED to find that the code for the various events of the controls contained in the panels would still run, because such code exists in the first form's file, not the displayed form's file. Luckily, it seems I was wrong. Event code follows the control itself. I can copy/paste not only controls, but also their corresponding event code to new forms for easier development and a faster Winforms designer.
All of this is similar to a MDI interface with maximized windows, but no title bar or [X] is displayed.
Essentially I'm doing everything as I did before, except using separate forms with panels instead of separate tabs with panels. The WinForms designer is much quicker because there aren't so many controls on any form.
I think I accidently found a workaround for saving a lot of time when changing the name of a control on a overpopulated container/project. Before you change the name, toggle False/True the "Generate Member" property of the control you want to rename(I believe you can also locate this under the "Name" property). This adds a few more clicks to the procedure but saves a lot of time. My not-yet-finished project has over 4000 controls and multiple forms and some of them are very "heavy" (10 - 20 seconds to normally change the name of a control). This, of course, don't help in anyway with the loading time of the project (about 35 seconds for me) but I can live with it. Let me know if this works for you too.