How can I add an array of controls to another control in VB.NET - vb.net-2010

I'm developing a menu component in VB.NET
I've created a component called menu and another one call button.
The idea is to add a collection of buttons to the menu.
For that I try without success create a public property in the menu component as an array of button components.
Does anybody know how can I achieve that?
I tried to create a public property in the menu component as an array of the buttons components.

Related

VB.NET Module-level variable to store count of child forms

In this exercise, you’ll create an application with a multiple-document interface that consists of a parent form and two child forms.
Open the project and add a parent form
1. Open the CalculateFlooringCosts project in the CalculateFlooringCostsMDI directory. Then, review the code for the Carpeting Costs and Hardwood Costs forms so you understand how they work.
Add a form to the project, and set the IsMdiContainer property of this form to True to identify it as the parent form. Resize the form so it’s large enough to hold several child forms, and use the Application page of the Project Designer to change the startup form to the new form.
Add the File menu to the parent form
Add a MenuStrip control to the parent form. Then, use the Menu Designer to add a File menu to the parent form. This menu should include four menu items that display a Carpeting Costs form, display a Hardwood Costs form, close the active child form, and exit from the application. Give each menu item an appropriate name, include access keys for the menu and menu items, and include a separator bar between the Close and Exit items.
Add an event handler for the Click event of each item in the File menu. The event handlers for the New Carpeting Costs and New Hardwood Costs items should create a new instance of the appropriate form, set the parent form to the current form, and display the form. The event handler for the Close item should close the active child form, if there is one. And the event handler for the Exit item should exit from the application.
Change the Exit buttons on the Carpeting Costs and Hardwood Costs forms to Close buttons, and change the StartPosition property of these forms to WindowsDefaultLocation.
Test the application to be sure that the items in the File menu work as expected.
Add the Window menu to the parent form
Add a Window menu to the right of the File menu. Then, add three items to this menu that will let the user arrange the forms in a cascaded, vertical, or horizontal layout.
Give each item in the Window menu an appropriate name, and then add an event handler for the Click event of each item that arranges the child forms appropriately.
Set the MdiWindowListItem property of the menu strip so the Window menu will display a list of the open child forms.
Test the application to be sure that the items in the Window menu work as expected.
Add a toolbar to the parent form
Add a ToolStrip control to the parent form. Then, add two buttons to this toolbar with the text “Carpeting Costs” and “Hardwood Costs” on them. Be sure to assign appropriate names to these buttons.
Add an event handler for the Click event of each button that uses the Click event handler for the associated menu to display the form.
Test the application to be sure that the toolbar buttons work.
Add a status bar to the parent form
Add a StatusStrip control to the parent form. Then, add a single ToolStripStatusLabel control to the status bar.
Add a module-level variable to the parent form to store the count of child forms, and give this variable an initial value of 0. Add code to increase or decrease the value of this variable each time a new form is opened or closed.
Add a procedure named DisplayFormCount that sets the Text property of the ToolStripStatusLabel control to “Number of child forms currently displayed: ” appended with the current form count. Then, add code to call this procedure when the form is loaded and each time the form count changes.
Test the application to be sure that the form count is displayed properly.
It's steps 15 and 16 I am stuck on.
I have tried this:
Private Sub DisplayFormCount(Sender As Object, e As EventArgs) Handles Me.MdiChildActivate
Dim activeForm As Form = Me.ActiveMdiChild
Me.sbMain.Items(0).Text = "Number of child forms currently displayed: " & Convert.ToString(Me.MdiChildren.Count)
End Sub
And it works for the most part. Upon form loading, it shows 0, then adding a form will make the count increase by 1. The problem is when I go to close the first child window, it doesn't subract. Afterwards all window closes reduces the count by 1 and when all windows are closed, it still says there's a count of 1.

How do i manipulate the data templates inside listbox in uwp

I am making a chat application using XAML in UWP.The side panel is consisting of users. like this.
Everything is in Listbox in which I have this template that consists one ellipse as a circle which is like an indicator,one user image,textblocks and one toggle switch.I have to give states to the toggle switch in on the state it should change the green color of circle and make it red.
I want to give this functionality in code c# in MainPage.cs. I made the object of toggle in toggled Event Handler but I am not able to access the other elements inside the data template like ellispse,textblock.
What is the other alternative way of doing this?
NOTE: It has to be in listbox because I want to use the same template for every user.
The best way to do this would be to use data binding.
You would define a ViewModel class for the item, which would contain a bool property and would react to the toggling of the switch in the setter or have a Command which you would execute when the state event changes using behaviors.
If you really want the code as a event handler on main page, you have some options. To get the item associated with the toggle, you can use its DataContext property and cast it to the data type you are using. Alternatively, you can use Visual Tree Extesnions provided by the UWP Community Toolkit. This enables you to find the parent (probably Grid) where you store all the item controls and then manually find the user image, TextBlock, etc.

How to use tooltip bootstrap in vb.net?

I'm working on project and I want to put a balloon tooltip like (html5) design on each textbox or another control
Here's an example:
I assume you're working in a Windows Forms project. To add Tooltips controls have to use the ToolTip class.
You can add design-time control from the toolbox of Visual Studio. In this way the properties of each control, you will see a new property called ToolTip in which you can set the text you want to appear.
Another option is acerlo for programming, creating an instance of the ToolTip class.
More information:
ToolTip Class

Get Dialog Box as the App Starts VB.NET

I want to know how to get a dialog box with two buttons as soon as the program is executed in VB.net.
Thanks!
PS - Help a novice programmer!
You can create yourself a new form with the buttons or controls you wanted. Then you could set this form as the startup form. You could do this by visiting the Project menu --> Project Properties --> Application tab --> Startup object. From the dropdown, select the form you created.
Then that form will be shown at first everytime you start your application.
Otherwise, you could use call the newly created form within your existing form's Load event, by calling the show() method of the new form.

how to call a public function inside child form in vb.net

i am having a toolstrip in the mdi form which contains save, update delete and clear buttons.
the child form is having save , update , delete and clear as public sub routines , and client form will not have any standard buttons, i will click the respective button in the parent tool window which should call the child forms function.
You can use delegates and events to do so. Define a delegate and an event in child form, define their handlers in parent form and call these handlers on click of the menus in parent form.