| | |
Sudoku
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
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 alignment app application array bitmap box c# c#gridviewcolumn check checkbox client color combo combobox communication concurrency control conversion csharp custom data database datagrid datagridview dataset datatable datetime degrees draganddrop drawing enabled encryption enum excel file focus form format forms function gdi+ getoutlookcontactusinfcsvfile globalization hospitalmanagementsystem image input install java list localization mandelbroth math messagebox microsoftc#visualexpress mono mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox save server sleep socket sql sql-server statistics string stringformatting sun table text textbox thread time timer update usercontrol validate validation visualstudio webbrowser winforms wpf xml






