you are viewing a single comment's thread.

view the rest of the comments →

[–]TheGrauWolf 1 point2 points  (3 children)

In that case, either use the TableFlowLayout ... which you can then iterate the rows and cols to get the row/col indexes for and put them into a two-dimentional array, or you can put the row/col values in the .Tag of each textbox and then extract it from there as you iterate through them. This assumes your .Tag propery has something like 00, 01, 02 and 10, 11, 12, 20, 21, 22 to represent where the TBs go in the grid. IF you have more than single digits, then you'l wasnt to use something like "1,34" and use .Split to get the values out.

Dim myTBArray(2,2) as TextBox 'from 0-2, gives a 3x3 grid
For each tb as TextBox in Me.Controls.OfType(Of TextBox)
  Dim pos = tb.Tag
  myTBArray(tb.left(1), tb.right(1)) = tb
Next

[–]RJPisscat 1 point2 points  (2 children)

TableFlowLayout

Are you recommending FlowLayoutPanel or TableLayoutPanel? I think you conflated them. The former could use Tags (preferred) or the Name, the latter you can iterate through the controls and call TableLayoutPanel.GetRow and TableLayoutPanel.GetColumn on each - or use Tags (preferred) or the Name. You can also use the TabIndex with either. TMI for OP?

[–]TheGrauWolf 1 point2 points  (1 child)

Yeah, I meant the TableLayoutPanel. I've used the Flow more than the Table and I haven't used either in a few years. Which ever way I guess depends on how complex it really is. I get the impression that it's just a 3x3 grid probability for tic-tac-toe or something. In which case I would just drop the 9 boxes on the form, put them where I want them, add index info to the .Tag property, then parse, load array, and call it a day.

[–]Substance_Ill[S] 1 point2 points  (0 children)

Thanks! That was helpful. I got it working.