|
Post by dragonjim on Mar 9, 2012 23:25:19 GMT 1
Just a quick question...
I need to create a multi-column list box and I'm assuming that Ocx ListView is the way to go.
I've set up the Column Headers and can import values into the first column without a problem.
My problem...I can't find a way of adding values to the rest of the columns.
Sadly, the Help File is of no use in this case. Please could someone tell me how to do this!
Either that, or could someone tell me how to create 'Continuous' record forms. Or both?!
Thanks in advance for all help proffered.
|
|
|
Post by 649psoft2 on Mar 11, 2012 9:42:49 GMT 1
You can have multi column appearance in a listbox but if you want to access the individual columns wihout changing the whole entry then use the listview.
***Access Listview Values****
'Global li As ListItem
'the Item array excludes the header and starts at 1 'the Subitems array dimension starts at 0
'to access an individual Listview item a row 'Set li = lv1.Item(2)
'MsgBox li.SubItems(5) 'accesses the 2nd row 5th element
'Alternatively this can be returned as a string
'Local a$ 'a$=lv1.Item(2).SubItems(15)
'Therefore the common form of a listview object 'is a 2 dimensional string array (in the report view) 'Alternatively at the selected Item row: 'lv1.SelectedItem.SubItems(0) = Random(9)
'****Access string of row elements****** 'lv1.ListItems(2).AllText '****
'****Remove a Item row****************** 'lv1.ListItems.Remove 2 'Item
|
|
|
Post by dragonjim on Mar 11, 2012 16:26:03 GMT 1
Once again, thank you for that. Stupidly, I missed the 'Columns' property in ListBox in the help file. However, what I can't find is a property or method to pre-determine the width of each column, and, giving it a trial run, I don't think ListBox fits the purpose of what I am proposing to do. Thank you for the information on ListView - sadly, again, this doesn't seem to replicate what I need to do, although it comes close enough that, if I can find no alternative, it may have to do. If it helps, I'll try and explain the effect I am trying to create. The ListBox needs to have a set number of columns, each containing different information relating to the same item. An example is below: Tax Code | Description | 3.40 | Direct Expenses | 3.41 | Indirect Expenses | 3.42 | Other Expenses |
With the information displayed as it is above, the user can then click anywhere on the required line (unlike in ListView but like a standard ListBox) to select the item and the entire length of the selected row is highlighted (unlike in ListView but like a standard ListBox). Sadly, neither ListBox (in multi-column mode) or ListView seems to fit the specifications. Is there anything within GFA that does? If the answer to the above is no, I wonder if you could explain how to add a Type object (data referring to the ListBox row) to a Collection within a second Type object (the actual ListBox object itself). Something like below: Type Multi_Column_ListBox . [other type variables such as height, width etc....] . mcb_lines As Collection End Type Type MCB_Line . ID As Word . Contents as String * 512 EndType Dim mcb2 as Multi_Line_ListBox Dim mcl1 as MCB_Line mcl1.ID = 1 mcl1.Contents = "Column 1|Column 2|Column 3" [/font][LINE TO ADD mcl1 TO mcb2.mcb_lines COLLECTION] With this information, I should be able to create an amateur-ish substitute for the OCX I require (which, hopefully, someone with a bit more computing knowledge might add to the ActiveX file?)
|
|
|
Post by dragonjim on Mar 12, 2012 1:00:14 GMT 1
Actually, hang fire on my last question. Looking through the documentation for Collections, unless I use a ListItem, it is unlikely to do me much good, I think. Am I right?
One matter you may be able to help on is the Control command which is, sadly, undocumented in the Help File (the reference I found to it was to do with 'Scrollbar'). I don't seem to be able to find it in the old German help file either, but, as my German is not so good, that probably isn't too surprising. Can you offer any insights on this command?
|
|
|
Post by 649psoft2 on Mar 12, 2012 9:58:54 GMT 1
Dragonjim you touched on 3 separate questions I will get to them in order.
[1]
First of all there is no 'columns' property in the Win 32 listbox and Gfa Basic 32 uses the Win 32 common controls.
I does not go beyond the common controls perhaps you might have seen an extended class somewhere?
Secondly if you refer to the Win 32 documentaton the listbox items are only strings.
So you can only use formatted or tabbed strings to make it look sort of but not really columnar.
Nearly every message to the Win 32 listbox common control object deals the placement or manipulation of a single line string.
You could do a lot of extra work in C but that is as far as the standard API goes.
[2]
The List View answers your problem as I explained it is a 2 dimentional array in an object.
example:
Put a listview on frm1 in the Form Editor and name it lv1.
Then use the following code in the code editor.
LoadForm frm1
lv1.Left = 20 lv1.Top = 20 lv1.Width = 200 lv1.Height = 120 lv1.Appearance = 1 lv1.TextBackColor = RGB(180, 200, 220) lv1.BackColor = RGB(140, 180, 240) lv1.View = 3 'report view lv1.FullRowSelect = 1 lv1.HideSelection = 0
lv1.MultiSelect = 0 lv1.GridLines = 1 'gridlines = True lv1.SetFocus lv1.SelectedItem = lv1(1)
lv1.ColumnHeaders.Add , "1", "Tax Code" lv1.ColumnHeaders.Add , "2", "Description" lv1.Add lv1(1).AllText = "3.40;Direct Expenses" lv1.Add lv1(2).AllText = "3.41;Inirect Expenses" lv1.Add lv1(3).AllText = "3.42;Other Expenses"
Do : Sleep : Until Me Is Nothing [3]
If you can create this object (multi column list box simular to a list view) you don't need it in the OCX File.
Sjouke Hamstra is maintaining it for operating system changes and fixing a few bugs he was an original Intermediary for GFA Basic.
The original .OCX file should not have any changes other than this.
If you want to extend the features then make another .OCX or .DLL or sort of library as an add on.
|
|
|
Post by dragonjim on Mar 12, 2012 13:09:29 GMT 1
Thank you again for the swift response. In reply:
[1] The property I was referring to in ListBox is the ListBox.Columns property which, if set to 0, gives the standard ListBox appearance, but if set to a value greater than 0 (and the Scrollbars property is set to 1 for Horizontal) will list all entries in "snaking columns, filling the first column, then the second column" and so on. However, in the sense of my original question, I agree with you that ListBox does not have such a specific Columns property.
[2] This is precisely the effect I was looking for and, if I'd spent a little bit longer working my way through the Help Page, I would have noted the all important FullRowSelect property and saved you the need for a reply. Thanks for your example and your patience.
[3] I understand your comments in reference to the OCX - my only thought was that, if there was not a facility within the OCX to deal with what is, in the world of VB and MS Access, a common control, it may have been an idea to add one. Now that I know it is there, I see that this is not the case.
In reference to my query about the 'Control' statement, it can be found on the 'Dialog Command' help page, just in case anyone else couldn't find it.
One final question on this matter, which I referred to in passing in my first post:
Is there a pre-defined way to create what I term 'continuous' rather than 'single entry' forms. To clarify: you wish to enter cash received on successive days over a period of a month. Rather than having one form with just a 'Date' field and a 'Receipts' field which you have to access many times to enter each individual amount for each day, is it possible to create a form with these two fields, which are then duplicated for however many days there are in that particular month?
|
|
|
Post by 649psoft2 on Mar 12, 2012 18:59:27 GMT 1
I have to get back to my projects but I will try to respond.
You can Add Items (or Rows) for each day in a listview with the Date And Receipts columns.
If you want a Single line Listview You can load and save the data for the Date And Receipts columns for each day.
I you want to duplicate a simular forms for for each day you would probably use the OCX command with the necessary variables.
Unfortuately for the controls the Form designer is a bit short on listview properties in the property sheet and this bothered me but if you left click in the editor after the dot as in (lv1.) most of the other properties will be shown in a listbox.
You can use the API with C like code to gain more control over some of the objects. Sadly there are the pitfalls of the Win32 API with some deprecated, not functional in every version, and a few constants with very limited value tacked on at the very end.
The Control statement is an alternative to the OCX statement for placing controls on to a Form/Window. I like this dynamic ability but the appearance of the controls still needs additional theme work to look more cool or modern.
The top of my wish list for Gfa Basic would be to add a few object classes and the abilty to create DLLs. This should be new fuctionality at the side of but not directly changing the existing OCX.
|
|
|
Post by dragonjim on Mar 14, 2012 16:11:28 GMT 1
Apologies for the late reply.
Thank you for your response and good luck with your projects. As I investigate the ListView OCX more, it has some interesting possibilities - if it allowed for text alignment in each of the columns (so that currency values could be right-aligned, etc) it would almost be perfect! Certainly, its built-in Sort method saves a lot of preparatory coding as does its ability to contain zero-width columns - the latter, used in conjunction with Sort, I found useful if when I wish to arrange the rows sorted by more than one column value.
As I said above, I understand your comments in reference to the default .ocx file. However, one last question...where would I post the rare errors/non-functionality I have noted with some of the Ocx objects?
|
|
|
Post by 649psoft2 on Mar 14, 2012 22:46:29 GMT 1
Sjouke Hamstra has asked people wanting to correct or know about a bug to provide a good discription of the bug and and an example of the bug in an email at gfabasic32@gmail.com Peter Heinzig at one time posted a bug list on his site www.peterheinzig.de
|
|