CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2010
    Posts
    10

    Copy selected text in a checkbox

    Yet another question arises. So far I have majority of my application finished, but the next problem has arisen.

    How do I go about copying text from a checked checkbox. I had it set so it would copy the text but it would copy it whether the box was checked or not. What string of text to do I need to add in to have it copy the checked boxes text?


    Btw...Happy Halloween Everyone!
    Last edited by klturi421; October 31st, 2010 at 06:22 PM.

  2. #2
    Join Date
    Aug 2008
    Posts
    902

    Re: Copy selected text in a checkbox

    I don't understand the question.

    What text are you talking about?

    Are you referring to a Windows.System.Forms.CheckBox.Text property? And if so, what do you mean by copy?

  3. #3
    Join Date
    Oct 2010
    Posts
    11

    Re: Copy selected text in a checkbox

    this might help:
    private void button2_Click(object sender, EventArgs e)
    {
    string[] checkeditems = new string[checkedListBox1.Items.Count];
    for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++)
    {
    checkeditems[i] = checkedListBox1.CheckedItems[i].ToString();
    }
    textBox3.Lines = checkeditems; //or you can do whatever you want with the array
    }

  4. #4
    Join Date
    Oct 2010
    Posts
    10

    Re: Copy selected text in a checkbox

    How would I combine the code above with the code I have below?



    private void button1_Click(object sender, EventArgs e)
    {
    string[] combotext = new string[12];
    combotext[0] = "text1 " + textBox2.Text.ToString();
    combotext[1] = "text2 " + textBox3.Text.ToString();
    combotext[3] = "text3 " + textBox4.Text.ToString();
    combotext[2] = "text4" + textBox5.Text.ToString();
    combotext[4] = "text5" + textBox9.Text.ToString();
    combotext[5] = "text6 " + textBox8.Text.ToString();
    combotext[6] = "text7 " + textBox7.Text.ToString();
    combotext[7] = "text8 " + comboBox1.Text.ToString();
    combotext[8] = "text9 " + checkBox1.Text.ToString();
    combotext[9] = "text10 " + textBox6.Text.ToString();
    combotext[10] = "text11 " + textBox11.Text.ToString();
    combotext[11] = "text12" + textBox10.Text.ToString();
    textBox1.Lines = combotext;
    }

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Copy selected text in a checkbox

    e tells you the .Index
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Oct 2010
    Posts
    10

    Re: Copy selected text in a checkbox

    i honestly have no idea what the e is referring to. I am just slapping this together. I have not a clue as to what any of this coding truly means other than what I am slowly picking up at the moment.

    What does e and .index have to do with eachother?

  7. #7
    Join Date
    Oct 2010
    Posts
    11

    Re: Copy selected text in a checkbox

    you need to have a second event trigger/button to transfer the checked items to do what you want with it.

    that is where the code i gave you comes into play

  8. #8
    Join Date
    Jul 2010
    Posts
    82

    Re: Copy selected text in a checkbox

    Any control's property can be read by getting its name during runtime. It can also be set similarly. Does e have a Name property here? You can use that retrieve checkbox control itself.

    May be you cna handle it in the checkbox_clicked event???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured