| | |
Sudoku
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
Hi Guys,
I'm making a program ( game sudoku) in C# - windows application which contains many textboxes (81) labeled as shown below.
String[] polja = { "tbA11", "tbA12", "tbA13", "tbA21", "tbA22", "tbA23", "tbA31", "tbA32", "tbA33","tbB11", "tbB12", "tbB13", "tbB21", "tbB22", "tbB23", "tbB31", "tbB32", "tbB33",...
... "tbI11", "tbI12", "tbI13", "tbI21", "tbI22", "tbI23", "tbI31", "tbI32", "tbI33" };
when i click on button "START", i'd like to fill some of that textboxes (25) with a random generated numbers 1-9 (int s). I was also created another random function for generate numbers 0-80 (int pol), which present indexes of string[] polja ....so far so good.
My problem is on the next step.
I need to convert string from polja ("tb..." ) to textbox with same name - e.q. tbA11.Text = s.ToString //for writting numbers 1-9 (int s) into.
(FindControl function doesn't work in my case)
my code.....
private void btn_start_Click(object sender, EventArgs e) {
NapolniPolje();
}
void NapolniPolje() {
for (int i = 0; i < 25; i++
{
int pol = new Random().Next(80); // for index 0-80
tbPolje.Text = pol.ToString(); //textbox for test only
int s = new Random().Next(9) + 1; //for numbers 1-9
tbRezultat.Text = s.ToString(); //textbox for test only
string txt = polja[pol]; //txt = "tb..."
Object obj1 = new Object();
obj1 = ((Object)txt);
TextBox tb = new TextBox();
tb =obj1 as TextBox ;
tbpolje1.Text = txt; //textbox for test only
tb.Text = s.ToString();
}
}
any ideas...
Regards
Bojan
I'm making a program ( game sudoku) in C# - windows application which contains many textboxes (81) labeled as shown below.
String[] polja = { "tbA11", "tbA12", "tbA13", "tbA21", "tbA22", "tbA23", "tbA31", "tbA32", "tbA33","tbB11", "tbB12", "tbB13", "tbB21", "tbB22", "tbB23", "tbB31", "tbB32", "tbB33",...
... "tbI11", "tbI12", "tbI13", "tbI21", "tbI22", "tbI23", "tbI31", "tbI32", "tbI33" };
when i click on button "START", i'd like to fill some of that textboxes (25) with a random generated numbers 1-9 (int s). I was also created another random function for generate numbers 0-80 (int pol), which present indexes of string[] polja ....so far so good.
My problem is on the next step.
I need to convert string from polja ("tb..." ) to textbox with same name - e.q. tbA11.Text = s.ToString //for writting numbers 1-9 (int s) into.
(FindControl function doesn't work in my case)
my code.....
private void btn_start_Click(object sender, EventArgs e) {
NapolniPolje();
}
void NapolniPolje() {
for (int i = 0; i < 25; i++
{
int pol = new Random().Next(80); // for index 0-80
tbPolje.Text = pol.ToString(); //textbox for test only
int s = new Random().Next(9) + 1; //for numbers 1-9
tbRezultat.Text = s.ToString(); //textbox for test only
string txt = polja[pol]; //txt = "tb..."
Object obj1 = new Object();
obj1 = ((Object)txt);
TextBox tb = new TextBox();
tb =obj1 as TextBox ;
tbpolje1.Text = txt; //textbox for test only
tb.Text = s.ToString();
}
}
any ideas...
Regards
Bojan
This thread already is about what you want I think.
http://www.daniweb.com/forums/thread180533.html
http://www.daniweb.com/forums/thread180533.html
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
![]() |
Similar Threads
- Sudoku Source Code (C++)
- Sudoku Source Code. (C#)
- Please help! Sudoku in C (C)
Other Threads in the C# Forum
- Previous Thread: timer control
- Next Thread: opening Excel 2003 file by c#
| Thread Tools | Search this Thread |
.net access algorithm array backup barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databasesearch datagrid datagridview datagridviewcheckbox dataset datetime degrees development draganddrop drawing dynamiccreation encryption enum equation excel file form format formatting forms function gdi+ hospitalmanagementsystems httpwebrequest image index input install interface java label list listbox mandelbrot math mouseclick mysql namevaluepairs operator path photoshop picturebox pixelinversion post powerpacks programming property radians regex remoting resource restore richtextbox running... server sleep soap socket sql stack statistics stream string table text textbox thread time timer update usercontrol validation visualstudio wait webbrowser windows winforms working wpf write xml






