This is a migrated thread and some comments may be shown as answers.

Cannot get the last item count

1 Answer 44 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Michelle Tan
Top achievements
Rank 1
Michelle Tan asked on 12 Oct 2012, 08:15 AM
Hi, I am new to telerik. I having problem with checking the last item in the listbox. Basicly it will loop alll the item in the listbox and combine it become a string, When listbox item reach end it will replace with "." instead of "',". Please help.Thanks
 
Dim sb As New StringBuilder    
 
For Each item As RadListBoxItem In radCustomer.Items
       
  If  radNotMemberOf.Items.Count.ToString.Length - 1 Then
 hdnCustomerList.Value = hdnCustomerList.Value & sb.Append(item.Value.Replace(",", ".")).ToString
Else
  hdnCustomerList.Value = sb.Append(item.Value & ",").ToString()
 
End If
      Next

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Oct 2012, 09:51 AM
Hi,

Try the following code to achieve your scenario.

VB:
If True Then
    Dim sb As New System.Text.StringBuilder()
 
    For Each item As RadListBoxItem In radCustomer.Items
        If item.Index = (AllAreas.Items.Count - 1) Then
            hdnCustomerList.Value = hdnCustomerList.Value + sb.Append(item.Value.Replace(",", ".")).ToString
        Else
            hdnCustomerList.Value = sb.Append(item.Value + ",").ToString()
        End If
    Next
End If

Thanks,
Princy.
Tags
ListBox
Asked by
Michelle Tan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or