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.
Related
I found a code for my project I have due online for Visual Basic. When I paste the code into Visual Basic and click run, is there a way for Visual Basic to make the form for me? Or do I have to make the forms myself based on the code?
You have to create the form yourself:
Create a Form.
Insert your existing code. Comment everything inside the class.
Create the controls.
Name your controls with the names your code needs.
Un-comment the previously commented code.
Have fun.
You can create different controls inside your class by code only as you wish, but you must create your form first, unfortunately this must be done manually
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.
I have 20 or so grids in my application suite. I'd like to create a global copy/paste context menu which I can bind to every single grid rather than code in each form.
I am unsure what is the best way to achieve this, I have started to create a class with my menu in it, but get stuck at the point of adding the actual menu options. For example I know I'll need to call a "copy" event, but I also know I'll need to tell it what I am copying, and I cannot see how that is done in vb.net when you can only add the address of a method minus parameters.
e.g.
.MenuItems.Add("Copy Cell", New System.EventHandler(AddressOf CopyCell))
Obviously I want "CopyCell" to only be coded in one place as well, rather than repeated in each form. I will always be copying the same object (SelectedCellCollection).
I am not sure how to make the menu have an event with parameters, or how to make it "know" that I want to always copy the selected items. I'm aware that I'd have to do some coding in the form but just trying to work out the way to minimize it.
I have created my own context menu class (via inheritance) with specific copy and paste functionality / options tailored to the grid I am using. It works fine and only needs one line of code per form/grid to activate.
I have this userform that i'm developing for my report formatting task. My whole code is finished, there are only 2 problems that i need to work on.
Making my VBA application work on every excel file that user choose
Exception Handling for ComboBoxes on my form.
(Edit: I hope trying to get attention of people who are interested in this question to another stackoverflow.com topic is not against forum rules)
You guys can reach first problem's topic from here: (There is already one suggestion but i'm little bit confused. So it would be super for alternative suggestions) http://bit.ly/VnF3cK
And about my second problem, when i click empty place of combobox, i can type whatever i want, but i want to restrict it, so users can only choose values [1-5] that i put inside of combobox. How can I achieve this?
In answer to your secondary question, you need to change the ComboBox's Style property to frmStyleDropDownList
I am given a task where I have this VB.Net script that produces and populates a grid and I must add coloring to each grid cell.
Problem is that this freeware given to me is 5 years old and I don't know what the name of this freeware is; I was only given the source files.
I am not entirely sure of how this script works because I am a C# person so I was hoping someone on here might know the freeware's name or what its functionality is so they can explain it to me.
There seem to be 4 files in the freeware folder and below is their screenshot:
I am currently sitting and trying to understand the code for PrintDGV.vb which might or might not be useful in understanding the freeware.
I am not familiar with any of these files but here is the code for PrintDGV.vb
Looks fairly straight forward.
You pass your DataGridView control to it and it looks like it will handle the printing for you:
Call PrintDGV.Print_DataGridView(YourDataGridViewControl)
It's a shared function so you don't need to instantiate it. For coloring your cells, just set the backcolor of your grid cells and it looks like it will use that in the printing process.
To change a color of an individual cell in the DataGridView control:
YourDataGridViewControl.CurrentCell.Style.BackColor = Color.Red