Sudoku

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 3
Reputation: bokr66 is an unknown quantity at this point 
Solved Threads: 0
bokr66's Avatar
bokr66 bokr66 is offline Offline
Newbie Poster

Sudoku

 
0
  #1
May 20th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,908
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 274
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: Sudoku

 
0
  #2
May 21st, 2009
This thread already is about what you want I think.
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC