*Experts* DiverDan Posted February 26, 2003 *Experts* Posted February 26, 2003 I have an Integer single dimension array that I need to multiply each element in the array by a factor then display the results into a multi columned listview. The length of the array will vary depending on the user's selection. Dim NumberArray() = {1,2,3,4} Or Dim numberArray = {1,2} .etc How can I multiply each element of the array by a new factor then display the results into a multi column listview? Thanks Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Leaders quwiltw Posted February 26, 2003 Leaders Posted February 26, 2003 Does it have to be a listview? or will a datagrid do? The reason I ask is that it'd be trivial to do using an expression column on a datatable behind a datagrid, but I think you're going to have to do it manually with listview, who knows though, I'm not very good at GUI stuff maybe someone else will have an idea. This should give an idea of what I'm talking about... Public Sub Init() Me.DataSet1.Tables.Add("mytable") Me.DataSet1.Tables("mytable").Columns.Add(New DataColumn("Initial_Val", GetType(Integer))) Me.DataSet1.Tables("mytable").Columns.Add("Factor", GetType(Integer), "Initial_Val * 5") Dim r As DataRow r = Me.DataSet1.Tables("mytable").NewRow() r("Initial_Val") = 5 Me.DataSet1.Tables("mytable").Rows.Add(r) Me.DataGrid1.DataSource = Me.DataSet1 Me.DataGrid1.DataMember = "mytable" End Sub Quote --tim
*Experts* DiverDan Posted February 27, 2003 Author *Experts* Posted February 27, 2003 Thanks Tim, but I would like to stick with the listview, although I do see your point. I've currently got the data in a string format, much like a CSV format, that is split into an array. From there I'd like to multiply each member of the array by a factor and display the results onto the listview. Unfortunately, the tables I'm working with are not uniform in any way and I don't think a standard database approach will work. Thanks Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
*Experts* DiverDan Posted February 27, 2003 Author *Experts* Posted February 27, 2003 (edited) Never mind, I've got it. Loading a CSV array into a multi column listview, with a multiplication factor: Get_NEC_Tables() lvConductors.Items.Clear() Dim AmountOfWires() As String AmountOfWires = WireQty.Split(",") Dim FirstItem As ListViewItem Dim OtherItems As ListViewItem.ListViewSubItem Dim count As Byte For count = 0 To AmountOfWires.GetUpperBound(0) If count = 0 Then FirstItem = New ListViewItem(CInt(FillFactor * AmountOfWires(count)).ToString()) Else OtherItems = New ListViewItem.ListViewSubItem() OtherItems.Text = CInt(FillFactor * AmountOfWires(count)).ToString() FirstItem.SubItems.Add(OtherItems) End If Next lvConductors.Items.Add(FirstItem) There is probably a better way of doing this, which I would appreciate seeing, but at least it works. Edited February 27, 2003 by divil Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.