Click here to Skip to main content
15,883,768 members
Home / Discussions / C#
   

C#

 
QuestionHow to combine drawing Pin
wgy_work20-Mar-13 19:04
wgy_work20-Mar-13 19:04 
AnswerRe: How to combine drawing Pin
Richard MacCutchan20-Mar-13 22:50
mveRichard MacCutchan20-Mar-13 22:50 
GeneralRe: How to combine drawing Pin
wgy_work20-Mar-13 22:56
wgy_work20-Mar-13 22:56 
GeneralRe: How to combine drawing Pin
Richard MacCutchan20-Mar-13 23:25
mveRichard MacCutchan20-Mar-13 23:25 
GeneralRe: How to combine drawing Pin
Wayne Gaylard20-Mar-13 23:29
professionalWayne Gaylard20-Mar-13 23:29 
AnswerRe: How to combine drawing Pin
TheRealRarius21-Mar-13 0:40
TheRealRarius21-Mar-13 0:40 
GeneralRe: How to combine drawing Pin
wgy_work21-Mar-13 14:15
wgy_work21-Mar-13 14:15 
QuestionReturn String from a CheckListBox Control Pin
PDTUM20-Mar-13 6:55
PDTUM20-Mar-13 6:55 
Seems simple enough, and I have looked hard and found many code sources (because some here might say this has been asked and answered), but none of them seem to work (I am showing some below...there are more).
Teh primary error seems to be the following error (unable to cast object of type 'system.data.datarowview' to type 'system.string ) or something similar to this. It seems like I solved this problem a while ago by giving up on the check list box and using a list view box with the show checkbox property added, but I cannot find my original code. So, in a nutshell....I want to simply return the string values for the checked items in the control and add them to an array or arraylist (either will do). BTW...the checklistbox control was filled using an SQL query (shown also), in case that makes a difference. You guys have almost always come up with a solution of sorts, and I thank you again in advance for your great assistance and talent...Regards, Pat

//Query Code
C#
 //Create an Arraylist to hold the values
                ArrayList al = new ArrayList();

                //Open a database connection for the reader
                Conn.Open();

                //Create the reader and execute the command adding the values to the arraylist
                SqlDataReader dr = Comm.ExecuteReader();
                if (dr != null)
                    while (dr.Read())
                    {
                        //fill arraylist
                        al.Add(dr[0]);
                    }

                //Close the connection
                Conn.Close();

                //Use the list to fill the checkbox
                foreach(string s in al)
                {
                    checkedListBoxServices.Items.Add(s);
                }

//ListCheckbox code I have tried

//This one returns just the first (or last) line.  I tried incrementing the row but it will not work

//foreach (DataRowView drv in checkedListBoxServices.SelectedItems)
            //{
            //    al.Add(drv.Row[0].ToString());
            //}
            ///////////////////////////////

//These do not work at all

//int i = 0;
            //int count = checkedListBoxServices.CheckedItems.Count;
            //object item = string.Empty;
            /////////////////////////////////
            //while (i < count)
            //{
            //    item = checkedListBoxServices.SelectedItems.ToString();
            //    listServices.Add(item);
            //    i++;
            //}
            ///////////////////////////////            
            //foreach (var item in checkedListBoxServices.CheckedItems)
            //{
            //    checkedListBoxServices.GetItemText(item);
            //}
            //////////////////////////////
            //string[] items = checkedListBoxServices.CheckedItems.OfType<string>().ToArray();
            //////////////////////////////
            //String[] itemArr = new String[checkedListBoxServices.CheckedItems.Count];
            //Int32 counter = 0;
            //foreach (ListViewItem item in this.checkedListBoxServices.CheckedItems)
            //{
            //    String temp = Convert.ToString(item);
            //    itemArr[counter] = temp;
            //    counter++;
            //}
            /////////////////////////////

AnswerRe: Return String from a CheckListBox Control Pin
Eddy Vluggen20-Mar-13 7:59
professionalEddy Vluggen20-Mar-13 7:59 
AnswerRe: Return String from a CheckListBox Control Pin
PDTUM20-Mar-13 8:45
PDTUM20-Mar-13 8:45 
GeneralRe: Return String from a CheckListBox Control Pin
Eddy Vluggen20-Mar-13 12:15
professionalEddy Vluggen20-Mar-13 12:15 
QuestionHow declare in wcf a typed class to avoid serialization duplication Pin
anymalo20-Mar-13 1:21
anymalo20-Mar-13 1:21 
AnswerRe: How declare in wcf a typed class to avoid serialization duplication Pin
Eddy Vluggen20-Mar-13 1:33
professionalEddy Vluggen20-Mar-13 1:33 
GeneralRe: How declare in wcf a typed class to avoid serialization duplication Pin
anymalo20-Mar-13 3:06
anymalo20-Mar-13 3:06 
GeneralRe: How declare in wcf a typed class to avoid serialization duplication Pin
Eddy Vluggen20-Mar-13 7:46
professionalEddy Vluggen20-Mar-13 7:46 
QuestionThreading inside WCF Pin
Nand3219-Mar-13 20:46
Nand3219-Mar-13 20:46 
AnswerRe: Threading inside WCF Pin
AmitGajjar19-Mar-13 20:58
professionalAmitGajjar19-Mar-13 20:58 
GeneralRe: Threading inside WCF Pin
Nand3219-Mar-13 21:28
Nand3219-Mar-13 21:28 
GeneralRe: Threading inside WCF Pin
AmitGajjar19-Mar-13 22:26
professionalAmitGajjar19-Mar-13 22:26 
GeneralRe: Threading inside WCF Pin
Nand3219-Mar-13 23:02
Nand3219-Mar-13 23:02 
GeneralRe: Threading inside WCF Pin
AmitGajjar19-Mar-13 23:05
professionalAmitGajjar19-Mar-13 23:05 
GeneralRe: Threading inside WCF Pin
Nand3219-Mar-13 23:07
Nand3219-Mar-13 23:07 
GeneralRe: Threading inside WCF Pin
AmitGajjar19-Mar-13 23:12
professionalAmitGajjar19-Mar-13 23:12 
AnswerRe: Threading inside WCF Pin
Manfred Rudolf Bihy19-Mar-13 21:18
professionalManfred Rudolf Bihy19-Mar-13 21:18 
GeneralRe: Threading inside WCF Pin
Nand3219-Mar-13 21:29
Nand3219-Mar-13 21:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.