3 Replies - 6360 Views - Last Post: 27 April 2008 - 10:52 PM Rate Topic: -----

#1 lohithahn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 21-October 07

How to displayindex in textbox of item checked in checkedListBox

Post icon  Posted 25 April 2008 - 12:26 AM

Hi,
Iam trying ti display index of iteam checked in checkedlistbox in Textbox with "," separating each index.....I have wriiten below code
Dim indexChecked As Integer
	For Each indexChecked In VoiceCodecCheckedListBox.CheckedIndices
				  TextBox.Text = (indexChecked.ToString() + ",")
		Next



This code display only the last index value of iteration. Previously wriitn index is overwritten by the next iteration. I just want to write all the index value in that textbox seperated by comma.
Please can anyone guide me.........

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: How to displayindex in textbox of item checked in checkedListBox

#2 ajwsurfer  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 373
  • Joined: 24-October 06

Re: How to displayindex in textbox of item checked in checkedListBox

Posted 25 April 2008 - 07:27 AM

You should use StringBuilder or a String to collect the values.


Dim Strb As StringBuilder = New Stringbuilder("")
Dim indexChecked As Integer

For Each indexChecked In VoiceCodecCheckedListBox.CheckedIndices
  Strb.Append(indexChecked.ToString() + ",")
Next

TextBox.Text = Strb.ToString



This post has been edited by ajwsurfer: 25 April 2008 - 07:28 AM

Was This Post Helpful? 0
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: How to displayindex in textbox of item checked in checkedListBox

Posted 25 April 2008 - 07:45 AM

An alternative method would be to just add to the existing values in the TextBox without overwriting them.
TextBox.Text = TextBox.Text + (indexChecked.ToString() + ",")

Was This Post Helpful? 0
  • +
  • -

#4 lohithahn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 21-October 07

Re: How to displayindex in textbox of item checked in checkedListBox

Posted 27 April 2008 - 10:52 PM

View Postjayman9, on 25 Apr, 2008 - 07:45 AM, said:

An alternative method would be to just add to the existing values in the TextBox without overwriting them.
TextBox.Text = TextBox.Text + (indexChecked.ToString() + ",")



Thanks for your valuable suggestion..Now iam getting wat i was required to get..But one problem iam facing is comma at last should be deleted

For Eg: In textbox now its disp[laying like this 1,2,3,
But i want "," after 3 should not appear. I tried
at last
Checkbox.text=checkbox.Text-"," but not working
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1