Hi Lee, first of all, you have to give the GridView a X, Y, width and height. Otherwise it's there but doesn't show.
To reference the GridViews, create an array of them and address them as GridView[0], GridView[1] and so on. The [i] is the number of the TabStrip index. Here is an example of what I did recently (tsTasks is the TabStrip): Private aTaskText As New Object[13] Private aTaskCheck As New Object[13] ... For i = 1 To 12 tsTasks[i - 1].Text = aMonths[i] tsTasks.Index = i - 1 aTaskText[i] = New TextBox(tsTasks) As "Tasks" With aTaskText[i] .X = 77 .Y = 21 .Width = 728 .Height = 35 End With aTaskCheck[i] = New CheckBox(tsTasks) As "CheckDone" With aTaskCheck[i] .X = 840 .Y = 28 .Width = 126 .Height = 21 .Text = ("done") .Tag = i End With Am 19.04.2017 um 01:58 schrieb T Lee Davidson: > Hello Folks, > > I have been trying to figure out how to, at runtime, create a variable number > of new tabs in a TabStrip, populate those tabs > with Controls, and then be able to reference those controls, all dynamically. > > There seems to be little information available as to how to 1) dynamically > create controls, and 2) reference dynamically named > controls after creation. > > Even with just a simple experiment, I cannot get a GridView to display in a > new tab. The Form has been given, at design-time, a > TabStrip and two buttons. The tabs are 'closable'. One button, 'btnAddTab', > creates a new tab and a GridView with the new, > current tab as parent. (At least that's what I think it is doing.) The other > button, 'btnTabInfo', displays info about the > currently selected tab. > > And, I am assuming the GridViews need to have unique names. > > [code] > ' Gambas class file > > > Public Sub btnAddTab_Click() > Dim hGridView As GridView > > TabStrip1.Count += 1 > TabStrip1.Text = "Tab " & TabStrip1.Index > hGridView = New GridView(TabStrip1) As "GridView" & TabStrip1.Index > hGridView.Show > TabStrip1.Refresh > > End > > Public Sub btnTabInfo_Click() > > Print TabStrip1.Children[0].Name > Print TabStrip1.Children[0].Enabled > Print TabStrip1.Children[0].Visible > > End > > Public Sub TabStrip1_Close(Index As Integer) > > TabStrip1.Index = Index > ' TabStrip1.Current.Children[0].Delete() 'Comment out to test if tab is > empty > TabStrip1.Current.Delete() > > End > [/code] > > > Tab creation works, but the GridView control does not display. Any attempt to > close a tab without first deleting its children > causes an exception, showing that the tab is indeed being populated with a > child control. Clicking on btnTabInfo for "Tab 1" gives: > GridView1 > True > True > > So, the program is doing at least some of what I've told it to. I'm obviously > not telling it the right thing. > > How does one: > 1. Create new controls and make them visible? > 2. Reference new controls after creation [ie. (de-)reference a string as a > the name of a control]? > > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user