Hello,
I have just started with Gambas3 and decided to write a Suduko program as a way of learning the language. I have some questions about how the design the GUI:
I need an array of 9x9 textboxes to capture the users input. I have found a example of how to create such an array within a program but I can't see how to set the edits. If I add the 81 boxes to the form at the design stage I can use the group property to capture the keypress event to ensure the user can only input single numbers between 1 and 9. Is there a way of adding a group property if they are created by the program?
Also the keypress event is good at ensuring only 1 - 9 gets input but I also need it to respond to tab, del, and up and down arrow input. Not sure how to do this?
Finally, (sorry for all the questions) what is the best way of adding lines to the form to surround and go between the text boxes?
Many thanks for suggestions
Array of Text Boxes
- cogier
- Site Admin
- Posts: 1125
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Array of Text Boxes
Welcome to the forum!
1/. There is a Sudoku program on the Gambas Farm (Tools>Software Farm) that could give you some ideas.
2/. I have started a similar program myself. I have attached it for you to look at but, it is not finished! The GUI is quite nice when resizing the Form.
This would also be a good place to check that only one number has been input, have a look at the Sub AllTBs_Change() at line 150 of FMain.
I hope this helps. I hope you enjoy your time with Gambas.
1/. There is a Sudoku program on the Gambas Farm (Tools>Software Farm) that could give you some ideas.
2/. I have started a similar program myself. I have attached it for you to look at but, it is not finished! The GUI is quite nice when resizing the Form.
If you are adding the 'Boxes' in the IDE then you can modify the 'Group' property there. If you want to create the 'Boxes' in code here is an example (you will need to add a loop to add more than 1).If I add the 81 boxes to the form at the design stage I can use the group property to capture the keypress event to ensure the user can only input single numbers between 1 and 9. Is there a way of adding a group property if they are created by the program?
Public Sub Form_Open()
Dim MyTextBox As TextBox
With MyTextBox = New TextBox(Me) As "AllMyTextBoxes"
.Height = 28
.Width = 28
.Text = "6"
End With
End
Public Sub AllMyTextBoxes_Change()
'Do stuff
End
The TextBox will be put on the Form (Me) and the Sub AllMyTextBoxes_Change() will capture any change made. Have a look at line 64 of FMain in my program.This would also be a good place to check that only one number has been input, have a look at the Sub AllTBs_Change() at line 150 of FMain.
There is a Seporator in the ToolBox but, I tend to use a Panel and change the background to Black. This way you can make it as thick, or thin, as you wish.Finally, (sorry for all the questions) what is the best way of adding lines to the form to surround and go between the text boxes?
I hope this helps. I hope you enjoy your time with Gambas.
Re: Array of Text Boxes
Many Thanks
This has got me going again!
This has got me going again!
Re: Array of Text Boxes
My little commentary here.
You can use the "tag" property of each textbox to know which one is being edited. That way you have one group but the "tag" can help you decide which textbox was active.
Cheers,
CR
You can use the "tag" property of each textbox to know which one is being edited. That way you have one group but the "tag" can help you decide which textbox was active.
Cheers,
CR
Dies ist kein Unterschrift.