473,386 Members | 1,810 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.

concatenate integer variable

Hello all,

I have a question about the concatenation operator in C#. For example, I
want to concatenate an integer variable to a control.

I have an integer, i. I have checkboxes, checkbox0 - checkbox5.
As I loop through my integers i - 5, I want to check my checkboxes,
checkbox0- checkbox5.

for (int i = 0; i < 5; i++)

{

checkbox+i+.checked = true;

}

However, referring to the checkboxes in the for loop as checkbox+i+.checked
= true is not working. Any help would be appreciated regarding
concatenating the checkbox control with the integer value.

-Tirrell
Mar 12 '06 #1
3 4683
Hi,

I assume that you are using winforms
If you have fixed set of controls - as in the example, you can write

checkbox1.checked = true;
checkbox2.checked = true;
checkbox3.checked = true;
.....

In such case, there is no need to write a loop.
HTH
Kalpesh

Mar 12 '06 #2
Bob
Hi,
You could use the checked changed event of each box to set an Array value
then just traverse the array.
private void checkBox1_CheckedChanged(object sender, EventArgs e)

{

//Code here to set Array member true if checked else false

}

HTH

Bob

"tirrell payton" <ti*************@hotmail.com> wrote in message
news:W7******************@tornado.tampabay.rr.com. ..
Hello all,

I have a question about the concatenation operator in C#. For example, I
want to concatenate an integer variable to a control.

I have an integer, i. I have checkboxes, checkbox0 - checkbox5.
As I loop through my integers i - 5, I want to check my checkboxes,
checkbox0- checkbox5.

for (int i = 0; i < 5; i++)

{

checkbox+i+.checked = true;

}

However, referring to the checkboxes in the for loop as checkbox+i+.checked = true is not working. Any help would be appreciated regarding
concatenating the checkbox control with the integer value.

-Tirrell

Mar 12 '06 #3


"tirrell payton" <ti*************@hotmail.com> wrote in message
news:W7******************@tornado.tampabay.rr.com. ..
Hello all,

I have a question about the concatenation operator in C#. For example, I
want to concatenate an integer variable to a control.

I have an integer, i. I have checkboxes, checkbox0 - checkbox5.
As I loop through my integers i - 5, I want to check my checkboxes,
checkbox0- checkbox5.

for (int i = 0; i < 5; i++)

{

checkbox+i+.checked = true;

}

However, referring to the checkboxes in the for loop as
checkbox+i+.checked = true is not working. Any help would be appreciated
regarding concatenating the checkbox control with the integer value.
C# can't do exactly what your asking - thank goodness.

What you want is an array (or other container) of controls.
For example:

for (int i = 0; i < 5; i++)
{
checkboxes[i].checked = true;
}

Try Googling "C# arrays" and "C# collections" for starters...

m


-Tirrell

Mar 12 '06 #4

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

Similar topics

2
by: Len Burman | last post by:
I have some code in a form which inputs a friends email address and when you submit it sends the message to the person at the address. I want to be able to email to the variable name and also a...
30
by: priya | last post by:
Hi How to concatenate two integer Values. Example Program : #include "Port.h" #include "BinaryConversion.h" # include "iostream.h"
6
by: Sheldon | last post by:
Hi, I am trying to build a large array using concatenate function in python. So as I loop over the number of arrays, of which there are 12 (4 down and 3 across), I create 3 long arrays by...
5
by: Generic Usenet Account | last post by:
I have been to recreate a problem that I am having with strings with the trivial code snippet given below. In the trivial code example, I am reading five lines from a data file, each line having...
5
by: malini | last post by:
Hi I have to concatenate an integer to an object created. something like this: for(int i - 0; i< ac.size();i++) { if ( ac->jack = A) {
2
jeffbroodwar
by: jeffbroodwar | last post by:
Hi, I want to concatenate 0x with a variable (dont know what type) to pass it in a byte array. the code below shows the original code : ORIGINAL CODE : ioData = new byte; ...
13
by: sinbad | last post by:
hi, how to concatenate a "hash defined" constant value to another "hash defined" constant string. For example #define ABC 100 #define MYSTR "The value of ABC is" Now i need a string that...
12
by: Nezhate | last post by:
Hi all, Is there any way to print a matrix's elements using a simple printf ? what I want as result is for example: if mat ={0,1,2,3} result must be: "0123". I tried this code: ...
1
by: Tony Bansten | last post by:
Assume I want to concatenate a literal text value and a variable value for a function parameter then the following does NOT work: objWorkbook.SaveAs("D:\work\v1_" + Filename) The variable...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.