Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Aask  
#1 Posted : Tuesday, January 8, 2019 1:48:15 PM(UTC)
Aask

Rank: Newbie

Groups: Registered
Joined: 11/14/2018(UTC)
Posts: 9

GetString returns the list of selected cells

Quote:
?iGrid1.SelItems.GetString()
(2,1);(4,1);(6,1)

GetArray returns a data structure that has two longs, Row & Column; the structure is TSelItemInfo.

Why doesn't GetArray simply return a 2-dimensional array whose first dimension is the number of cells (ROWS) and two Columns? (Row,Col)

Another question: how would you define

Quote:
Dim arr() As TSelItemInfo

when using late binding?

Edited by user Tuesday, January 8, 2019 11:34:03 PM(UTC)  | Reason: Not specified

Igor/10Tec  
#2 Posted : Wednesday, January 9, 2019 3:10:39 AM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,015

Thanks: 14 times
Was thanked: 130 time(s) in 130 post(s)
1: Do you need to know the number of selected items? SelItems.Count contains this value.

2: Try to use Variant.
Aask  
#3 Posted : Wednesday, January 9, 2019 3:32:34 AM(UTC)
Aask

Rank: Newbie

Groups: Registered
Joined: 11/14/2018(UTC)
Posts: 9

- I am familiar with Count (in the context of the number of selections). However, I did not find an Item property wherewith to loop up to Count.

1. If I am using late binding, (as opposed to adding a reference to iGrid), how can I create an instance of TSelItemInfo? I am thinking of something like:

set xyx = CreateObject(?.?) (as an alternative to Dim arr() As TSelItemInfo).

where I am struggling to find what ?.? would be.

As far as I know, Variant will cope with different data types but NOT with data structures like TSelItemInfo which is a data structure containing Row & Col.

2. If the argument to SelItems.GetArray is optional (as shown in the help file) why is it looking for an argument; SelItems.GetString has the same signature as SelItems.GetArray but it does NOT insist on an argument.

PS: With my client, I can use late binding only.
Igor/10Tec  
#4 Posted : Wednesday, January 9, 2019 7:08:45 AM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,015

Thanks: 14 times
Was thanked: 130 time(s) in 130 post(s)
Very interesting - SelItems does not have the GetString method. Perhaps, it's the time to ask you: what is your development environment?

As for using Variants, the following code works in VB6:

Code:
Dim i As Long
Dim arr As Variant

arr = iGrid1.SelItems.GetArray

For i = 1 To UBound(arr)
   Debug.Print arr(i).Row; arr(i).Col
Next
Aask  
#5 Posted : Wednesday, January 9, 2019 10:25:26 AM(UTC)
Aask

Rank: Newbie

Groups: Registered
Joined: 11/14/2018(UTC)
Posts: 9

Quote:
Very interesting - SelItems does not have the GetString method.

Interesting indeed! It does - see attached picture showing the intellisense dropdown.

getArray.png

GetString is NOT in the help file but is in the Grid object.

Edited by user Wednesday, January 9, 2019 10:57:20 AM(UTC)  | Reason: Not specified

Aask  
#6 Posted : Wednesday, January 9, 2019 2:39:07 PM(UTC)
Aask

Rank: Newbie

Groups: Registered
Joined: 11/14/2018(UTC)
Posts: 9

There is a mix-up regarding the GetArray and GetString method of the SelItems object. Both GetArray and GetString take identical and optional arguments.

Quote:
GetArray method:
Result@Array_Custom_TSelItemInfo lMinRow@Long lMaxRow@Long lMinCol@Long lMaxCol@Long ← WI 'GetArray' [lMinRow@Long [lMaxRow@Long [lMinCol@Long [lMaxCol@Long]]]]
Returns the array of the currently selected items.


Quote:
GetString method:
Result@String lMinRow@Long lMaxRow@Long lMinCol@Long lMaxCol@Long ← WI 'GetString' [lMinRow@Long [lMaxRow@Long [lMinCol@Long [lMaxCol@Long]]]]
Returns the string that represents the currently selected items.


The GetString method is not documented in the help file.

The GetString method is expected to return a 4 element numeric array. It doesn’t. In fact, it returns the selected cells (Row, Column) and the 4 element numeric array.

Quote:
(2,1);(4,1);(4,2);(6,1);(6,3) 2 6 1 3


This is the result that GetArray is supposed to return.

GetArray simply does not work for me – I’ve tried many combinations of arguments.

The help file example for GetArray shows it returning Custom_TSelItemInfo – there is no indication that the other 4 numeric elements are returned.

Omissions/Errors:

1. The GetString method needs to be included in the help file.

2. GetString returns a 5 element result - the result appears to be the result that GetArray should be returning.

3. Both GetString and GetArray take optional arguments yet GetArray is demanding an argument.


I believe some corrections/enhancements are required in order to align the published public interface of the grid with the interface that is actually exposed.

Edited by user Wednesday, January 9, 2019 11:05:53 PM(UTC)  | Reason: Not specified

Igor/10Tec  
#7 Posted : Thursday, January 10, 2019 8:49:17 AM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,015

Thanks: 14 times
Was thanked: 130 time(s) in 130 post(s)
OMG! I completely forgot that we added the SelItems.GetString() method in one of the latest builds of iGrid. It's hard to keep all changes in the brains when you are working with thousands of customers :)

The help file is really missing the corresponding topic, but we'll definitely fix that in the next public update of the control.

As for the method output, I re-checked it. In my tests it always returns a string according to the template

Quote:
(row1,col1);(row2,col2);(row3,col3)...


Can you send us a sample demonstrating your problem? It seems you are using iGrid in a VBA-based environment. I asked you about your dev env but have not received any answer.
Aask  
#8 Posted : Thursday, January 10, 2019 10:29:53 AM(UTC)
Aask

Rank: Newbie

Groups: Registered
Joined: 11/14/2018(UTC)
Posts: 9

No problem; I know from personal experience how easy it is to forget/overlook the change history of large projects.

I look forward to the updated help file. Also, since GetArray will work with a variant array - as you've posted - you may want to include that example in the help file too.

I still have some issues with GetArray/GetString, the least of these is to understand why both are necessary. I'll explain further and provide further step by step explanation/illustration of the issues: I'll send this to your email address.

May I suggest some enhancements for the future?

1. A method, say, SaveSession, which will save the content only of the grid as XML to a file; the name of the file will be the argument to the method. Of course this will require a complementary method, say, RestoreSession which will read the file back into the grid.

Of course if you want to introduce further flexibility, you could cater for JSON (and CSV) documents as well as XML ones. The format can be another argument to the methods.

2. A method, say, SaveSessionStyles, which will save the objects e.g. combo boxes etc., formatting, and cosmetic aspects of the current grid. RestoreSessionStyles will be the complementary function.

My reasons for this suggestion are:

1. XML, CSV, and JSON documents are ubiquitous.

2. Saving the whole session and being able to restore it promotes rapid presentation of the grid in a user interface. It should be possible to restore the contents only, or the contents and styles in any order. I am thinking of contexts where the workflow requires Resume i.e. continue from where I left off.

3. A supplementary advantage will be that you can, within reason, load any XML (or JSON) into the grid.

4. These methods will enable users to acquire and transfer data with ease. When an XML file is read into the grid, users can use, say, ReadIntoArray to acquire the data in their own environment. Saving to a file in a generic format such as XML also makes it easy for users to transfer data from their environment to any other application that can read XML.

Edited by user Thursday, January 10, 2019 10:52:11 AM(UTC)  | Reason: Not specified

Igor/10Tec  
#9 Posted : Friday, January 11, 2019 6:36:56 AM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,015

Thanks: 14 times
Was thanked: 130 time(s) in 130 post(s)
Originally Posted by: Aask Go to Quoted Post
I still have some issues with GetArray/GetString, the least of these is to understand why both are necessary.


I do not remember exactly, but we implemented the GetString method for a customer who could not use GetArray in his development environment (obviously, it was not a VB/VBA-based dev env). A string returned by GetString was the only way to provide information about the selected items.

*****

Thank you for your suggestion regarding the Save/Restore methods. Let's continue this discussion in email correspondence as this thread is dedicated to the SelItems property.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.