I have a form I am designing for work, and there are 3 combo boxes I want on it that display the same choice (unit of measurement selection). Now instead of 3 separately named boxes, I wanted to make an array of combo box, now I thought if I created 1, then copy pasted it would make them an array as the same name but it just lists the new one with a default name.
I cannot work out the correct formatting of the above type addressing for a textbox in a (sort of) array of textboxes such as
textbox_1 textbox_2 textbox_3 etc.
The controls are on Tabs but I don't think I need to include the Tab as a container control, just refer directly to the textbox on the form, but I cannot work out how this is done in VB .NET format. In VB6 it was relatively straightforward but VB .NEt seems it is different. Can anyone help me with the correct way to formulate
This was an experiment to see if I could create a fake array using generics instead of using an array. I decided to try it, because I may use it if I find any advantages to using it over an array. it works, I am just asking for a second or third opinion, have I screwed anything up, or is there an easier way to accomplish this? If I use it, it will be for a 2D game I am creating, and is used to draw the 2D screen graphics, placing an image based on what image identifier is located at what coordinates. The value stored in the fake array is an integer that disignates the graphic to draw and whether it is passible or not, i.e. 0 = a floor image, 501 = a wall image that is impassible (any image number > 500 is impassable) The Class definition:
I need to be able to refer to a set of controls on a Windows form using an array, but I'm having a few difficulties.
The Windows form (WForm.vb) contains two textboxes (TextBox1 and TextBox2).
In Module1.vb I have created an array reference to the textboxes thus:
Public wf As New WForm Public ReadOnly TB() As Control = {wf.TextBox1, wf.TextBox2}
Then, in WForm.vb I have tried to refer to the textboxes via the array:
eg.
TB(0).Text = "Change text to this"
I know that the array is referring to the textboxes, because when I hover the cursor over the line 'TB(0).Text = "Change text to this" ' in debug mode, I get the following:
(0)|{Text = "Change text to this"} (1)|{Text = ""}
but for some reason, the text in TextBox1 on the form isn't actually being changed! (There is obviously no problem with change the textbox's text at this point in the code, because I've tried substituting the array reference 'TB(0)' with a direct reference to the textbox 'TextBox1', and the problem disappears.
I've been making a table control for a few days, and I've got to the point of making it capable of accepting new data. To do this, I'm making it generate a row of text boxes, combo boxes, and date selection windows along the row that you're entering data into.
I've tried using an array of 'control' types and changing them to whatever specific control I need as I generate it. That sort of works. For example, the code under 'Case "Employees"' below will make a combo box display on the form, but 'ControlArray(i).Items.Add' gives an error because it doesn't think that ControlArray(i) is actually a combobox yet.
You might also be interested to know that everything will have to be dynamically generated since the table I'm using will not always be the same (and the Select Case code will eventually be replaced by something that checks for relationships in the database).
Dim ControlArray(NumberOfColumns - 1) As Control For i As Integer = 0 To NumberOfColumns - 1 ControlArray(i) = New TextBox
figure out a way to link datagridviews to other controls like a combobox, list view or even another datagridviewBecause much of the code is managed by the IDE, I was expecting an IDE approach to linking controls. Is this the case or do I have to modify the generated code to do what I want.An example would be to use a combobox to limit the number of entries in a datagridview etc
I am trying to make a form that is blank and will add in 2 comboboxes, a textbox, 2 buttons and a checkbox next to each other in a row. I want the controls to be part of an array, so that all controls on a row are associated with that array number.I am currently able to make the first row appear when the form is loaded, however when i click one of the buttons(which are used to create thenext row of controls) it comes up with an error stating that the index was outside the array bounds.
Here is the code I currently have:
Public Class frmWhere Public SQLString3 As String Public locationy As Integer
I am not sure, but I have understood that, if I want an array of controls with only a method that handles a particular event, I have to define a custom control and add the handler. Is it possible that it does not work with an array of normal controls?
I'm writing an application in VB.NET and face the following issue. I'm trying to create an interface that will allow the user to select their availability given a range of times and the days of the week. I want to create checkbox controls in a tabular form with two indices that I can use to refer to a certain time range and a day of the week.[code]I followed the article found here which creates and exposes a control array,however it is not multi-dimensional. Does anyone know of a similar way to dynamically generate controls and store them in a multi-dimensional array in VB.NET?
If you have a Component (or Control) with a public property of type Control, then in the Properties Window you automatically get a drop down of all the controls on the same form as the component, which is very handy. If you want to do the same thing but with an array of controls then the Properties Window shows the ellipsis and you get the Collection Editor with the Add / Remove buttons creating and deleting an instance of Control (i.e. the base class used for deriving all the others) - not quite so handy.
How do I get a list of the controls on a form and be able to select more than one? I think I need to create a custom UITypeEditor? Assuming that's right then I think I need a dialog box (like the Font dialog) with Available and Selected ListBoxes with Add / Remove buttons and appropriate code to link the control array in the component to changes in the Selected list box? Along with an appropriate UITypeEditor derived class.
Assuming that's correct, how do you get a list of the controls on a form at design time? Can I do that form design as a Windows Form, just as normal, or is it all done by hand? I've seen some code that does it with a UserControl rather than a Form, presumably that's for when you want a 'pop-up' control (like the one for Color selection)?
I am new to VB 2008 express (I am a 'C' coder but have played with VB6 before). I am writing a simple program that will use the serial port. What I would like to do is, upon some trigger event, open a form, and depending on the amount of serial ports available, populate this form with an array of checkboxes with each check box corresponding to an available serial port. The user could then choose a port which would then determine the PortName.
I am creating an array of customer controls by doing the following: Dim CtlLosArray(150) As Control
Then I'm setting up the first control in the array like this: CtlLosArray(1) = New ShieldLOSInfobox CtlLosArray(1).Location = New Point(0, 0) CtlLosArray(1).Visible = True CtlLosArray(1).Show() CtlLosArray(1).Name = "Label1" Me.pnlLOS.Controls.Add(CtlLosArray(1))
Now on this custom control I have a panel and a few text boxes and as you can see I may be adding about 150 of these custom controls. What I am wanting to do is to be able to access that control then the item on that control based on the array. Something like the following: CtlLosArray(1).Controls.Item(Panel1).backcolor = Color.Yellow But the above does not work. How I can access a specific item on the customer control within the array?
I need codes for array controls radio button. My program is to have auto-generated radio button, when i declare no. in numeric up down that will be the no. of set of the radio button. the program is an exam generated for true or false if you will think of it to have an radio button options for true or false. if i will click the generate button then the radio buttons will appear.
I'm working on an menu program right now which has 20 panels used to display bmps that can be clicked on to select things. These panels are simply named something like pnl01, pnl02, etc. to pnl20. I'd like to make them into an array, like pnl(0) through pnl(19), so i can change the bmp on different panels like this:
x = 7 pnl(x).backgroundimage = image.fromfile(file)
i thought this had something to do with enumerated controls but after some searching i couldn't figure out if i was looking for the right thing.
I am trying to access a dynamically generated Control from a separate thread. But I am always getting a "Stack Overflow Exception" with my code. I am using following code:
I need to use an array at any part of the project. It has been suggested to me to build an array and show its result in a combobox. Instead of having an input textbox, i will have a combobox which will display 10 common names which are kept in the array.
'Defines the array Names Dim names(9) As String 'Defines the array's fields[code]......
So the premise of an assignment I'm working now is that I will read lines from a txt file, eventually have a user select a combo box for a city, and then have the current timezone and time in that city.
For reference, each line in the file contains three tab-delimited sections which I need to access for varying purposes. An example of the format is:[code...]
What I have so far (below) is the file being read, splitting each section of the line into a multidimensional array, and then combining the "columns" into an array structure (I'm not too hot on using an array as a structure, so I may be doing something wrong).
[code...]
Now assuming everything there is alright (I have a feeling something may be wrong in regards to the structure) I need to fill out the combobox with only the Location, and have that change the current time and timezone (located on the GUI as labels).
Where I've been stumped at for the past few days is how to proceed from here. I've been trying to populate the combo box, but all my attempts have failed and I'm starting to think it may be because of the method I'm using to do all this.
In VB6, if I copy and paste a combobox on the form, VB6 automatically asks if I want to create a control array. VB2005 does not do this when I copy and pasted on the form. How can I create control array for comboboxes on the form similar to VB6 method?
The below code is a sample code that is supposed to display the months in a combobox.
Dim months() As String = _ {"Select a month...", "January", "February", "March"}
[code]....
But what am I supposed to do with this code? I have created and named the combobox "cboExpirationMonth", but where do I put this code? I tried to put it as a click event of the combobox, but that doesn't work. I created a button and tried to put the code in the button's click event, but that still doesn't populate the combobox.
Trying to create a set of controls that can be used repeatedly without copy and paste code, including a textbox, a set of radiobuttons and then another textbox. Having a major problem in that I can only get one radiobutton to show up.
vb.net Public Class QuestionDisplay Inherits Windows.Forms.GroupBox
What would be the best approach to create the following: A groupbox that contains several labels a groupbox with an array of 8 labels in it
Then the main form would have 4 of these groupboxs (object?) and I would need the ability to change the color and text of all the various labels within any of the groupboxes, using an index similar to what we could do with control arrays in VB6.
I would think an object would make the most sense but can you have control elements in an object and display them on the form?