Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, November 26, 2024 
 
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!
 Architect Forums - SalesLogix Scripting & Customization
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.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Listview Checked event...
Terry Keane
Posts: 12
 
Listview Checked event...Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Aug 06 9:53 AM
fiogf49gjkf0d
Hi,

I am using a listview with check boxes. There doesn't seem to be an event that captures when the user checks/unchecks the box. I tried putting code on the OnSelectItem event but that didn't fire when I checked the checkbox.

Anyone have any ideas on going about how to do this?

Thanks.
Terry
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Listview Checked event...Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Aug 06 12:15 PM
fiogf49gjkf0d

Public Function GetCheckedItems
'Function
' Returns an Array of Strings of checked items in a ListView

'Syntax
' GetCheckedItems

'Parameters
' None

' Returns
' Array of Strings
dim integerIndex, integerItemsCount, integerUBound
dim stringResult
On Error Resume Next
stringResult = ""
if (not (m_listview is nothing)) then
redim stringResult(0)
with m_listview
integerItemsCount = .Items.Count - 1
for integerIndex = 0 to integerItemsCount
if (.Items.Items(integerIndex).Checked) then
if (stringResult(0) = "") then
stringResult(0) = .Items.Items(integerIndex).Caption
else
integerUBound = UBound(stringResult) + 1
redim preserve stringResult(integerUBound)
stringResult(integerUBound) = .Items.Items(integerIndex).Caption
end if
end if
next
end with
if (stringResult(0) = "") then
stringResult = ""
end if
end if
GetCheckedItems = stringResult
ErrorCheck(Application.Translator.Localize("SFCListView.GetCheckedItems:"))
On Error Goto 0
End Function

OnSelectItem doesn't fire because technically the row isn't selected. OnClick or OnMouseDown may be the only event you have that will do what you're suggesting.

Instead of processing on each check, I do processing on the AXFormValidate event of the form my listview is on. The GetCheckedItems method lets me store the array of primary key values in a memo field which I then serialize back into checked items when the form is reopened.

In 6.1 I used a listview in this configuration to mimic a multi-select datagrid. 6.2 datagrids are multi-select so you may have a better time using a datagrid instead of a listview. There may be a way to hack something together using my method above but it'd be difficult to narrow it down to just one selected value.
[Reply][Quote]
Terry Keane
Posts: 12
 
Re: Listview Checked event...Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Aug 06 12:47 PM
fiogf49gjkf0d
Thanks Jeremy!

I was going to have an item that would read "Check All" and have that followed by a list of items. So, when the Check All box was checked, it would check, well, all of them for the user. If it was unchecked it would uncheck everything.

I didn't see the OnClick or OnMouseDown events on the Event tab that appears on the Properties Page. So I assumed they weren't available. I tried creating my own event and that didn't work.

I might have to take the Check All option off. No biggie.

Thanks again.
Terry
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Listview Checked event...Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Aug 06 2:08 PM
fiogf49gjkf0d
Here's the SelectAllItems method I use:

Public Sub SelectAllItems
'Sub
' Checks all of the checkboxes of a ListView with Checkboxes = true

'Syntax
' SelectAllItems

'Parameters
' None
dim integerIndex, integerItemsCount
On Error Resume Next
if (not (m_listview is nothing)) then
with m_listview
integerItemsCount = .Items.Count - 1
for integerIndex = 0 to integerItemsCount
.Items.Items(integerIndex).Checked = true
next
end with
end if
ErrorCheck(Application.Translator.Localize("SFCListView.SelectAllItems:"))
On Error Goto 0
End Sub

m_listview in both methods is the listview object itself (set m_listview = ListView1).

You could use a popupmenu that would be triggered on the OnMouseDown event of the ListView (and only when the right mouse button is pressed). Store a boolean that determines when select all has been triggered. This way you can use the same popupmenu item to trigger both a select and deselect instead of using 2 menu items.
[Reply][Quote]
 Page 1 of 1 
  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!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/26/2024 8:45:46 AM