6/19/2025 9:28:29 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
|
|
|
|
Adding to a listview
Posted: 11 Jul 07 1:53 PM
|
How do I add rows to a listview with 2 columns? This should be easy, but I cannot figure out how to do it. Here is what I am trying to do:
Set rs = conn.Execute (strSQL) While Not rs.EOF ' Here I want to add a row Set li = ListView1.Items.Add li.SubItems.Add rs.Fields(0).Value li.SubItems.Add rs.Fields(1).Value rs.MoveNext Wend
Thanks,
Lloy |
|
|
|
Re: Adding to a listview
Posted: 12 Jul 07 6:23 AM
|
Lloy, here is some code that may help. I set up two columns in the listviews column properties - I am actually populating two list views at once with this code - NewRow populates one listview, NewRow2 populates the second - but you should be able to get the gist..:
Sub PopulateListView(Sender)
Dim strsql, objConn, objRS, sAmount, sCheck, sWireAmt Set objConn = New SLX_DB 'Get fund totals grouped by currency strSQL="Select Sum(A1.Amount_Allocated) as amt , B1.Currency, B1.Commited as fundamt2 " & _ "from sysdba.C_OPP_ASSETALLOCATION A1 " & _ "left Join sysdba.C_OPP_SECURITIES b1 " & _ "on a1.split_assetID = b1.C_Opp_SecuritiesID " & _ "where a1.c_opportunitiesID = '" & txtOppID.text &"' and b1.ACASECAS='T'" & _ "group by B1.Currency, B1.Commited " set objRS = objConn.GetNewRecordset objRS.Open strSQL, objConn.Connection Dim NewRow, NewRow2 lvNetProceeds.Items.Clear lvCheck.Items.Clear Do While NOT objRS.EOF Set NewRow = lvNetProceeds.Items.Add Set NewRow2 = lvCheck.Items.Add Select case objRS("currency") Case "EUR" NewRow.Caption = objRS.Fields("currency").Value NewRow.SubItems.Add formatNumber(txtTotalEUR.text)
NewRow2.Caption = objRS.Fields("currency").Value NewRow2.SubItems.Add formatNumber(txtTotalEUR.text-WireTotalsByCurrency(objRS("currency"), txtICSDetailID.text)) Case "USD" NewRow.Caption = objRS.Fields("currency").Value NewRow.SubItems.Add formatNumber(txtTotalUSD.text)
NewRow2.Caption = objRS.Fields("currency").Value NewRow2.SubItems.Add formatNumber(txtTotalUSD.text-WireTotalsByCurrency(objRS("currency"), txtICSDetailID.text)) Case else NewRow.Caption = objRS.Fields("currency").Value NewRow.SubItems.Add formatNumber(objRS.Fields("amt").Value)
NewRow2.Caption = objRS.Fields("currency").Value NewRow2.SubItems.Add formatNumber(objRS.Fields("amt").Value-WireTotalsByCurrency(objRS("currency"), txtICSDetailID.text)) End Select
objRS.MoveNext Loop objRS.close Set objRS = Nothing set objConn = nothing End Sub |
|
|
|
Re: Adding to a listview
Posted: 12 Jul 07 8:17 AM
|
Steve, Thanks for the reply. I'm still not getting what I want, so maybe if I post the entire code, someone can tell me what I am doing wrong. Thanks.
strSql = "Select Product_Style, Sum(Field_Visits) From Metro_Type_Visits" strSql = strSql & " Where AccountId = '" & strAcctID & "'" strSql = strSql & " Group By Product_Style" Set conSLX = Application.GetNewConnection Set rs = conSLX.Execute (strSql) ListView1.Items.Clear ListView1.Columns.Item(0).Caption = "Style" ListView1.Columns.Item(0).Width = 200 ListView1.Columns.Item(1).Caption = "Planned Visits" ListView1.Columns.Item(1).Width = 80 ListView1.Columns.Item(2).Caption = "Actual Visits" ListView1.Columns.Item(2).Width = 80 While Not rs.EOF ' Dim li Set li = ListView1.Items.Add li.Caption = rs.Fields(0).Value li.SubItems.Add rs.Fields(0).Value li.Caption = rs.Fields(1).Value li.SubItems.Add rs.Fields(1).Value rs.MoveNext Wend rs.Close Set rs = Nothing conSLX.Close Set conSLX = Nothing
The result I get is a listview that contains just the second field (the sum) like as follows
[1 4 17]
It doesn't even look like my column widths are being set properly. Thanks for the help.
Lloy |
|
|
|
Re: Adding to a listview
Posted: 12 Jul 07 8:52 AM
|
What are you doing here? Set li = ListView1.Items.Add li.Caption = rs.Fields(0).Value li.SubItems.Add rs.Fields(0).Value li.Caption = rs.Fields(1).Value li.SubItems.Add rs.Fields(1).Value rs.MoveNext
refererencing Caption TWICE in the same row? The Caption is the Row title (over on the left). You can have a Row ID as well (.TAG). That helps you know where you are for mouse clicks, updates, and such.
Set li = ListView1.Items.Add li.Caption = rs.Fields(0).Value li.SubItems.Add rs.Fields(0).Value '''''''''li.Caption = rs.Fields(1).Value li.SubItems.Add rs.Fields(1).Value li.SubItems.Add rs.Fields(2).Value li.SubItems.Add rs.Fields(3).Value li.SubItems.Add rs.Fields(4).Value li.SubItems.Add rs.Fields(5).Value
rs.MoveNext
OR Set newRow = lvTerrByState.Items.Add '''Value of the row ID newRow.tag = TerrState '''TerrUSERID ''' List View ROW LABEL. newRow.caption = TerrState '''' Add values to the list view? newRow.SubItems.Add TERRusername newRow.SubItems.Add TERRCode
|
|
|
|
Re: Adding to a listview
Posted: 12 Jul 07 9:30 AM
|
Thanks for the help guys, I finally figured out what was wrong. Apparently you have to set the ViewStyle property to vsReport. It defaults to vsIcon. Once I did that, I was able to get it to work. Thanks again. |
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|