473,513 Members | 8,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pre-defined PictureBox[], now null?!

Samishii23
246 New Member
I have 132 PictureBoxs in an array. 44 in 3 seperate panel controls.
At the load up, all the PBs are defined, set to their appropriate places, and given their appropriate attributes. Then the panels are hidden for later use in the program.

Later when I run my method to show the appropriate PBs based on user input. When though I have initilized all the PB and what not. They all return Null when I try modify them in my method, and cause my program to short-circuit...

I don't understand why they are all Null after I declared them all, already...
I've also tried to go through them all again with the = new PictureBox(); in a loop. But the all the PBs I set earlier don't change. And if I don't use the = new, then the program errors out.

Any ideas why this is happening?
Feb 14 '10 #1
4 2106
tlhintoq
3,525 Recognized Expert Specialist
When you make them the first time, are you adding them to a List<PictureBox> or a PictureBox[], that has a global scope so you can reference them elsewhere?

When you try to access them based on user input are you trying to reach them through that List<> or Array?

Maybe it would help if you could show the method where you make them, and the method where you later try to access them.
Feb 14 '10 #2
Samishii23
246 New Member
Expand|Select|Wrap|Line Numbers
  1. namespace frm_main {
  2.  class TCMain {
  3.   public PictureBox[] TIcon = new PictureBox[132];
  4.   TCMain() {
  5.    for (int i; i<132; i++) {
  6.     this.TIcon[i] = new PictureBox();
  7.     // Loads X,Y Position / Names /  Border Style... Exc
  8.    }
  9.   }
  10.   // Runs on User Click
  11.   LoadFromUser() {
  12.    for (int i; i<DataClass.Count(); i++) {
  13.     // I have used this.TIcon, and just TIcon. Both with error.
  14.     TIcon[i].Image = new Bitmap(DataClass[i]);
  15.     // Hide or display some icons as well, and other such things... exc...
  16.    }
  17.   }
  18.   static void Main() {
  19.    Application.Run(new TCMain());
  20.   }
  21.  }
My TCMain() is almost 300 lines long. Thats a good summary of it, since its kind of a static variable / control. The Click Method is in the same Class as TCMain, and where the definition is for TIcon.

When I get the RunTime error, the Local Variable viewer Shows TIcon[] has 132 null instances.

But the thing is is when I show the 3 panels that all these PictureBoxes are in... All 132 of them are there... Granted they are just outlines. They are in their appropriate positions, and sizes... So I don't understand why they are null?
Feb 15 '10 #3
tlhintoq
3,525 Recognized Expert Specialist
Expand|Select|Wrap|Line Numbers
  1. public string[] TIcon;
  2.    for (int i; i<132; i++) {
  3.     TIcon[i] = new PictureBox();
  4.  
WTF? You make a string array, then try to make an element of the string array a new PictureBox? Dude... Go get some sleep before you continue working on this: Obviously you are so sleep-deprived that you can't think straight anymore. I've been there MANY times where the simplest thing like this eludes me at 3 a.m.

Each element of a string[] is a string, not a picturebox.

You need to make a picturebox array to hold a bunch of pictureboxes.\

Expand|Select|Wrap|Line Numbers
  1. public PictureBox[] TIcon;
  2.    for (int i; i<132; i++) {
  3.     TIcon[i] = new PictureBox();
  4.  
Feb 15 '10 #4
Samishii23
246 New Member
Sorry sorry, after I posted string[] I fixed it about a minute after my original post...

Thanks for the quick reply though!
Feb 15 '10 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
10176
by: Headless | last post by:
I've marked up song lyrics with the <pre> tag because it seems the most appropriate type of markup for the type of data. This results in inefficient use of horizontal space due to UA's default...
3
3769
Pre
by: Neal | last post by:
A few questions about pre... When presenting preformatted text using the white-space: pre; property/value, Opera renders long lines at small viewport widths as exiting the borders of the...
7
18513
by: Alan Illeman | last post by:
How do I set several different properties for PRE in a CSS stylesheet, rather than resorting to this: <BODY> <PRE STYLE="font-family:monospace; font-size:0.95em; width:40%; border:red 2px...
2
2774
by: Buck Turgidson | last post by:
I want to have a css with 2 PRE styles, one bold with large font, and another non-bold and smaller font. I am new to CSS (and not exactly an expert in HTML, for that matter). Is there a way to...
5
24083
by: Porthos | last post by:
I'm authoring an XML document and using the <pre> html tag for the portions that are not dynamically generated. The <pre> text is displaying in a smaller font size (and I believe different font)...
5
718
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
8
3768
by: Jarno Suni not | last post by:
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0. Why is there the difference? Can that pose a problem when such a XHTML document is served as text/html?
7
2732
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
14
3603
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
0
7254
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
7373
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
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.