473,387 Members | 1,365 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,387 software developers and data experts.

C# APP "CheckedListBox to array"

Hi, i am fresh grad and having some problems. the problems as below and iIt is quiet urgent.........

i have two CheckedListBox (CLBa and CLBb) , and i want the user selected CheckedListBox is assign to two dimension array.

Objective:
There is a sql statement (select * from tblname where field1= ' ' OR field2=' '),
i want to allow user to choose the data for filetring,

where
- field1 will read selected item in CLBa
- field2 will read selected item in CLBb
- the sql statement is use for 1 table only

possibility
- single row might have selected data in field1 and field2
- row is not duplicated in the result of select statement

solution
- i plan to assign the selected item in CLBa and CLBb to a two dimensional array
- from the array i read the data and filter

problem
- how to assign the selected in both check box list to an two dimension array?



Thank you
Dec 5 '08 #1
1 4733
Ramk
61
Try using this with jagged array. It loops the number of items selected in CLBa checkedlistbox.
my2DArray[row][0] -> Will fetch the CLBa object.
my2DArray[row][1] -> Will fetch the CLBb object.

Expand|Select|Wrap|Line Numbers
  1.  
  2. private void button1_Click(object sender, EventArgs e)
  3.         {
  4.             CheckedListBox.CheckedItemCollection si1 = checkedListBox1.CheckedItems;
  5.             CheckedListBox.CheckedItemCollection si2 = checkedListBox2.CheckedItems;
  6.             Object[][] my2DArray = new Object[si1.Count][];
  7.             int row = 0, it2=0;
  8.             int obj2Cnt = si2.Count;
  9.             foreach (Object s1 in si1)
  10.             {
  11.                 Object s2 = new Object();
  12.  
  13.                 if (it2 < obj2Cnt)
  14.                 {
  15.                     s2 = si2[it2];
  16.                     it2++;
  17.                 }
  18.                 my2DArray[row] = new Object[2] { s1, s2 };
  19.                 row++;
  20.             }
  21.         }
  22.  
Dec 6 '08 #2

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

Similar topics

7
by: Arnaud | last post by:
Hi, I work with php 4.3.4 and I don't understand the way php sort this array for example : <? $array = (-1, 30, "test", true); sort($array); var_dump($array); ?>
6
by: sonic | last post by:
what exactly is the difference ? I think that is more suitable for declarative arrays, but not exactly sure why. TIA
4
by: Greg Stark | last post by:
I find myself wishing I had a syntax "LIKE ANY (array)". I don't see much value in the = ANY, = ALL, <> ANY, <> ALL syntax since they're equivalent more or less to IN and NOT IN. But it could be...
2
by: Simon Morgan | last post by:
I hope this isn't OT, I looked for a newsgroup dealing purely with algorithms but none were to be found and seeing as I'm trying to implement this in C I thought this would be the best place. I...
3
by: Pablo Gutierrez | last post by:
I have a C# method that reads Binary data (BLOB type) from a database and returns the data an array of bytes (i.e byte outbyte = new byte;). The BLOB column is saved into the database by a C...
2
by: Rick Francis | last post by:
I need help serializing an array without including the array "name". I am writing in C# and using the XmlSerializer to serial classes. I am trying to serialize a class with an array in it like...
30
by: josh | last post by:
Hi all, what does it meaning that strange sintax (look at the object :) ? if I have i.e. array.length I can use array. and is it IE/Firefox compatible??
26
by: drako | last post by:
Hi, I'm a bit stumped as I am getting a "Notice: Array to String Conversion" error when trying to do something that on the surface should be a very simple task - create an array, and write a set...
8
by: arnuld | last post by:
i have created a solutions myself. it compiles without any trouble and runs but it prints some strange characters. i am not able to find where is the trouble. ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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...

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.