VBA Adding a User Defined Control to Userform at Runtime - vba

So I've made the following control in Design Mode then added the control to a new page Custom in my toolbox.
Now, what would I use for the progID parameter in Controls.Add()? How do I look up this value? Controls.Add("Forms.Frame.1") adds a regular frame, not the desired custom control.

As far as I am aware, you do not generate a new progID with a custom control. Per the MSDN documentation for custom/modified controls:
Note: When you drag a control onto the Control Toolbox, you only transfer the advanced property values.
So only the properties are transferred; the actual control is still of the same type/s as the one you created it from. Further, it looks like this progID is "a unique system-wide string that the Windows operating system can use to identify your control's type." So unless you are up to coding your own control, it looks as though you're just passing properties to the custom toolbox controls you create there.
You'll have to just replicate the custom control each time you want to add it. Just create a sub with all the correct properties and call it. Not what you were looking for, but it'll get the job done.

Related

Vba activate grid control as additional control

I want to add control to user GUI that would represent excel like table but I cannot find additional control that would do that. Control like that would be used for easier data entry.
I believe that VBA has control like that and I am missing something obvious.
Does anyone know where to activate control like that?
If you have VB6 installed then, this should work:
Microsoft Flex Grid Control
However, if you do not have (vb6) then, another option is to create one yourself by dynamically adding controls to your UserForm (such as a textbox) and then tracking those object. It would take some work, but it would be an option.

Add custom control to toolbox and have its properties show up in the properties window

To illustrate what I'm asking, let's say I have a custom TextBox that has 2 modes. Mode 1 only allows numbers, and mode 2 only allows dates in a particular format.
Using a class module I can create this custom TextBox, and I can use a loop when the userform initialises to set which TextBoxes are custom.
What I'd like to happen is have the custom TextBox, or what ever custom control I want, show up in the toolbox. And I also want its custom properties, if they exist, to show up in the property window.
So far, I've been unable to find a way to do this. In fact, I've been unable to find out if it's even possible. It seems, to me anyway, that it's something that should be possible, but maybe I'm barking up the wrong tree. If it's possible I'd really appreciate being pointed to a resource.

undo for non textbox controls

new to .net coming from vba decided to rewrite a management app using vb.net and SQL Server.
Started writing the base library for my application.
I created custom controls to use in my application that would expose a Zoom function, background color for the current active control a .modified property similar to the one available in textbox and some extra other properties (SQLTableName, SQLColumnName, ...) to enable iterating through a container (form) for modified controls and Update/Insert into a SQL table via a SQLProcessClass.
Concurrently I'd like to also implement a simple undo functionality.
My first idea was to add a PrevValue variable set in the OnEnter event if the Modified property is False, exposing an OldValue property and an Undo method in the custom controls.
However I found that the TextBoxBaseClass already exposes an Undo method and that there is an UndoEngineClass available.
Unfortunately the vs helpfile does not give examples of how to use / implement that class.
Could someone explain the usage of the UndoEngine class non-textbox controls and if it is advisable to use it or rather write my own (as I first intended to do - I also found some interesting articles about undo/redo classes) but why reinvent the wheel in case .net already provides a class for it.
thks

How can I derive a control to an inherited form in VB.Net?

everybody.
I have a VB form (named "MyBaseForm"), with an ImageList control ("MyIcons").
I want to derive MyBaseForm to another form ("MyDerivedForm"), allowing it to use MyIcons ImageList defined into the base class.
Of course what I want to do is to use the images of MyIcons to define MyDerivedForm with Designer and/or into the code.
To do that, i set MyBaseForm.MyIcons.Modifiers property to Protected (I also tried with Public and Protected Friend, with the same results...)
In this way, I expect that if i modify the MyIcons image list from the Designer view of MyBaseForm, I would find the change into MyDerivedForm.
But, if i for example add a new image to MyBaseForm.MyIcons, MyDerivedForm.MyIcons keeps being still unchanged.
It looks like when i create the derived form, VisualStudio just create a copy of the ImageList control. Which is not what i want.
To have MyDerivedForm.MyIcons updated, what I have to do is to manually remove the "MyIcons" section of file MyDerivedForm.Designer.vb, so that, when I re-build, VisualStudio re-generates that section.
Is there a way to have that control REALLY derived, or, alternatively, to force the compiler to re-create MyDerivedForm.Designer.vb at any build (without having to manually manipulate the self-generated code)?
(I am using VB.Net 2005)

How to identify a specific ActiveX Interface based on limited information

I am in the process of developing an ActiveX control for embedding in Rockwell Automation's Factory Talk View. (See ActiveX DLL Error: Solved to see how great a start I got off to!)
At the moment I have an ActiveX control that seems to embed into the host system OK, but is not fully integrated into the VBA process. I believe that this is because I have not implemented some specific COM interface that is required, but I have no documentation as to what that is. I do know that standard MS controls like the Microsoft Forms 2.0 controls do implement the required interface and fully integrate.
The key functionality I am missing relates to a property that I need to set in order for my VBA code to actually see the ActiveX object. This property can be seen when opening the property panel for any activeX control placed on a Factory Talk screen, but NOT when looking at the properties of ActiveX controls embedded in (for example) Excel. Thus I am probably trying to chase down some custom Rockwell implementation. I am hoping that SO might be able to give me some aid into how to track down what I want based on recognizing the functionality it implements.
Now to the actual property. In Factory Talk the property is called "ExposeToVBA", and has a type "long". You have a choice of 3 values selected from a drop down list:
Not Exposed - When set to this, the controls name is not even visible to VBA code
Type Info Extension - Not sure what this does
VBA Control - VBA code can see and interact with the control.
When I select anything other than "Not Exposed" for my control, I get a warning dialog box with no text on it. For other controls I need to set it to "VBA Control" in order to interact with it in the VBA code (d'oh)
I suspect that the value of this property is translated into some calls to an ActiveX interface on the target control.
The Question
What I want to do is identify what interfaces something like a "Forms 2.0 Label" implements that would match the above functionality. And also perhaps how I could translate this into my C# based control (based on C# ActiveX control (CSActiveX))
I know its a long shot, but I'd appreciate any and all suggestions
This became moot when I found a canned Active-x control that had the functionality that I needed.
FWIW This is what I believe that I used: DMGraph