Click here to Skip to main content
16,006,065 members

Comments by luccingolo (Top 2 by date)

luccingolo 7-Apr-11 18:21pm View    
Hi Mika, thank you for joining the discussion. But I'm not trying to combine two separate datatables. I am only trying to display the data of a related childdatatable in a ListBoxelement. I would like to display the listboxitem's number in front of the item itself. So, for example, if there are five items in the listbox, then they should be numbered from one to five. If the same listbox contains ten items, then these items should be numbered from one to ten...and so on. I use a datatemplate with two textboxes to diplay the data in the listbox. The first textbox for the number of the item, and the second textbox for the item itself.
The first problem is to find out how many items the listbox will be composed of every time the current related datarow of the parenttable changes. And then the first textbox of the listbox's datatemplate will have to be bound to the items number.(from 1 to listbox.items.count)
In my project I dont get the data right from the datatables but I "load" it in a data-entity model. And this entity-model is the "source" for my ViewModel-Class where a public ChildView-property(and a public parentView-property as well)of ICollectionView-Type keeps the updated childdatarows. At this time I have bound the textbox of the listbox's datatemplate to this public childview of my viewmodel-class. And now I hope that somebody can show me how to bind the other textbox of this datatemplate, to get a number for every listbox-item.
So I hope that now it's a little bit easier for you to understand what I'm trying to do here.
Thanks,
luccingolo
luccingolo 10-Nov-10 13:31pm View    
Hi Henry Minute.
So I hope you will get an email this time. Thanks to you I have at least learnd how to post an answer....
The way the guys from MSDN solved the iteration problem is not realy what I was loking for.
In the MSDN-example they get an integer value from the Datatable.

Dim colCount As Integer = view.Table.Columns.Count

But in my projekt the data I'm working with is held in a BindingSource.
The way i finally settled it is the ItemArray property of the Datarow object.
Dim myDR As DataRow = CType(Me.myBS.Current, DataRowView).Row

For Each fieldContent In myDR.ItemArray
Console.WriteLine("Item: {0}", fieldContent.ToString)
Next
But I thank you for your help. Your answers gave me the "keywords" to google for.
And last but not least.... You told me to add a comment to your answer. Thats what I'm doing right here.
But this "Submit comment-Textbox" offers no "text or code enhancement facilities". Shoudn't I use this "Add your answer here"-box below to type my comment????

Thanks