MH-SudokuSolver ver 1 Implementation Issues

A couple of design issues had to be tackled:

If you look at a Sudoku puzzle in the newspaper, you can see thick lines after every three cells horizontally and vertically. Each of these 3x3 sub-grids is called a box. To get the effect of the box, I first used the TableLayoutPanel cotainer but did not know how to get the thick line effect. So I discarded it.
Then I used nine different group boxes but discarded that also because when I brought the group boxes close to each other, one of the edges just disappears. Next, when I located one text box next to each other, exactly next and not overlap, then the two edges appear as a thicker line. Finally, my solution. I used one group box and filled it up with 81 textboxes.

Now the text boxes have to take take one digit as an input and the solution was to handle the key press event to accept only the digits 1 -9.  But the program has 81 cells. Luckily I found in Visual C# 2005, A Developer's Notebook about the control MaskedTextBox in which the mask can be set to an optional digit (the mask being #9). That was quite a relief because I was thinking of how to implement handler(s) for the 81 text boxes. I changed to 81 MaskedTextBoxes.
The java program uses a HashMap. In my C# program, I have used a Dictionary, the equivalent of HashMap.
HashMap h = new HashMap();
Dictionary<string, string> dict = new Dictionary<string, string>();
if (h.get(""+j) == null) {
if (!dict.TryGetValue(j.ToString(), out value)) {
Java get: Returns the value to which the specified key is mapped in this identity has map, or null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it is also possible that the map explicitly maps the key to null. [Source: ]
Initially I tried ContainsKey
(if (!dict.ContainsKey(j.ToString())) {
but then changed to TryGetValue.
C# TryGetValue: When a program often has to try keys that turn out not to be in the dictionary, TryGetValue can be a more efficient way to retrieve values. [Source: ]

Back          Home