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.
Related
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.
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.
I googled a lot but I had absolutely no luck finding anything about my problem.
I would like to create ListBox - just like the one anyone can create using UserForms. The problem is that I do not want to draw it but write it with a code. I know how to add values to ListBox etc. The only thing I am missing is how to create it programatically.
I found this: Creating form programmatically in the module using vba but this code didn't work for me. It stops at declaring Forms.
The idea behind this ListBox is to create a ListBox to choose from sheets in a workbook to later do some stuff.
Me.Controls.Add ("Forms.Listbox.1")
allows you to add a control at runtime only using an event procedure.
I'm trying to do a scheduler for a lesson schedule. Which control should I use and how to do?
Here you find an image of what I'm trying.
You should create a UserControl based on the "DatePicker" control.
And then redefine the control template, using a UniformGrid.
There is no simple and quick way to do that yourself. Either you recreate a custom control based on a DatePicker, or you try to find a library of controls already doing what you are trying to.
I believe a few controls already exists to do that, but I don't have names to throw in.
Few years ago I used to program with Visual Basic 6, I was able to create objects with the same name, then differ them by the index.
for example, we can create TextBox1 and another TextBox1 but with a different index.
now this feature is not available anymore!
Currently, I'm using Visual Studio 2012.
Is there anyway to manipulate VS2012 to enable that feature again, or is there something similar to it, because it was really helpful.
The easier way to accomplish a similar thing today is to place all of these controls in a common parent control. This parent could be a groupbox, a panel, or even the form itself.
So if, say, all of the checkboxes on your form need to be indexed, with no exception, you don't have to do anything special. If just one checkbox is different, you need that checkbox to have a different parent control than your indexed checkboxes. In this case, you could layer a panel control under the checkbox group, or you can layer a panel control under the single checkbox that is different. Either will work.
Later on, you will still not be able to access these checkboxes by index, but you will be able to treat them as a collection. Here's how you can do that:
For Each box As CheckBox In Me.Controls.OfType(Of Checkbox)()
'Do something with each checkbox
Next
Or if you want to know which ones are checked:
Dim checkedBoxes As IEnumerable(Of Checkbox) = Me.Controls.OfType(Of Checkbox)().Where(Function(b) b.Checked)
If you really want an array of the checkboxes, you can use this technique to get one. Just put code like this in your form's load event:
Dim checkBoxes() CheckBox = Me.Controls.OfType(Of CheckBox)().OrderBy(Function(b) b.Name).ToArray()
It's horrible painful now.
MSDN covers this subject now: http://msdn.microsoft.com/en-us/library/aa289500%28v=vs.71%29.aspx
Long live VB6!