473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to display my 2 dim array on a Form containing a matrix of labels?

First time poster.

I have a class which creates a two dimensional array of objects that hold an int. When I populate this array with int objects, I'd like to pass the array which I call a grid to a form holding a matrix of labels. I then want to output the 2 dim array using ToString val by val to each label on the Form.

I can instantiate the Grid object in the Form Class and access the methods in the Grid class, but when I try to use the [, ] operator I get the error "Cannot apply indexing with [] to an expression of type 'grid'.

Expand|Select|Wrap|Line Numbers
  1.  private void fillGrid(SudokuGrid grid)
  2.         {
  3.             int i = 0;
  4.             int j = 0;
  5.  
  6.             foreach (Control control in tableLayoutPanel1.Controls)
  7.             {
  8.  
  9.                 Label originalLabel = control as Label;
  10.                 if (originalLabel != null)
  11.                 {
  12.                    originalLabel.Text = grid[i,j].val.ToString();
  13.                     //originalLabel.ForeColor = originalLabel.BackColor;
  14.                     j++;
  15.                     if ((j == 9) && (i < 9))
  16.                     {
  17.                         i++;
  18.                         j = 0;
  19.                     }
  20.  
  21.                 }
  22.             }
  23.         }
  24.  
  25.  
Not sure what to do next here and I'd appreciate any help.

Thanks,

H
Jan 24 '11 #1
0 1034

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Nick | last post by:
Hi, I am tring to display a form that does not show in either the task bar or when the user alt-tabs. The form is running full screen and is set to have no border. Nick
1
by: Mr Utkal Ranjan Pradhan | last post by:
Hi Friends I want to develop a windows service application, which will open a port on the machine and constantly it will listen from that port. And when any data comes to that port I want to...
2
by: Bernie Yaeger | last post by:
I have developed a .dll to display a form that controls a simple routine. Oddly, you can't use messagebox.show unless you do one of two things: either use an imports system.windows.forms or...
3
by: Brett Romero | last post by:
My application start like this: frmMaster MainForm = new frmMaster(); System.Windows.Forms.Application.Run(MainForm); The flow is that MainForm shows then a SecondForm shows after the user...
0
by: yasker | last post by:
Hi, I got a problem in display a sub form. My app contains two form: main and sub. I want sub form display before main form, to provide some information to it. I use a NotifyIcon to activity...
5
by: Paul | last post by:
Is it possible to display a form inside another form? What component should I use?
4
ak1dnar
by: ak1dnar | last post by:
I need to display a form dynamically. First i load the page and at that time Login button will display. Nothing else. If some clicks the Login button, then only I want to display the Form. So...
1
by: Zaher Rabah | last post by:
How can I display a form in dialog mode by press any keys in the keybaord in access 2003. This form is used as calculater "For fast calculate" This is the idea.
2
by: menyki | last post by:
please can somebody help me debug this code. i wrote a code that will display a form within an interval but the is generating alot of errors. the code is as shown below. (am using visual basic.Net) ...
1
by: menyki | last post by:
am designing a software. in the software i want the splash to display for sometime, say 1 minute then it will close and the main form will come up. i included timer control in the splash form i...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.