Re: help with ListView code?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help with ListView code?

mikeB-2
Greetings all,
I've got a Listview (set as Column view) with 2 columns that I'm using

for testing so I might understand how all this works so can add it to a
project.

testCode..................................................
With listview1
     .Clear
     .Resizable = True
     .Columns.Count = 2
     .Columns[0].Text = "Site Name:"
     .Columns[1].Text = "Site URL:"
End With
..................................................................
I can add values to the 1st column:
code..........................................................
listview1.add("1", "First var entry")
listview1.add("2", "Second var entry to test the resize ability")
listview1.add("3", "Third var entry")
...................................................................
Have spent a lot of research time trying to figure out how to add
values to the 2nd column (Site URL:) - got me stumped.

Anyone got an example line of code to help me out?

I can't seem to find the answer in the help docs.

Would greatly appreciate any/ all help;-)
mikeB


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help with ListView code?

Fabien Bodard-4
Le 28 juil. 2017 07:12, "mikeB" <[hidden email]> a écrit :

Greetings all,
I've got a Listview (set as Column view) with 2 columns that I'm using

for testing so I might understand how all this works so can add it to a
project.

testCode..................................................
With listview1
    .Clear
    .Resizable = True
    .Columns.Count = 2
    .Columns[0].Text = "Site Name:"
    .Columns[1].Text = "Site URL:"
End With
..................................................................
I can add values to the 1st column:
code..........................................................
listview1.add("1", "First var entry")
listview1.add("2", "Second var entry to test the resize ability")
listview1.add("3", "Third var entry")
...................................................................
Have spent a lot of research time trying to figure out how to add
values to the 2nd column (Site URL:) - got me stumped.

Anyone got an example line of code to help me out?

I can't seem to find the answer in the help docs.

Would greatly appreciate any/ all help;-)
mikeB


------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user

Simply :

ListView ["1"]="myvalue"

Where "1" is the key of the line value
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help with ListView code?

Tobias Boege-2
In reply to this post by mikeB-2
On Thu, 27 Jul 2017, mikeB wrote:

> Greetings all,
> I've got a Listview (set as Column view) with 2 columns that I'm using
>
> for testing so I might understand how all this works so can add it to a
> project.
>
> testCode..................................................
> With listview1
>     .Clear
>     .Resizable = True
>     .Columns.Count = 2
>     .Columns[0].Text = "Site Name:"
>     .Columns[1].Text = "Site URL:"
> End With
> ..................................................................
> I can add values to the 1st column:
> code..........................................................
> listview1.add("1", "First var entry")
> listview1.add("2", "Second var entry to test the resize ability")
> listview1.add("3", "Third var entry")
> ...................................................................
> Have spent a lot of research time trying to figure out how to add
> values to the 2nd column (Site URL:) - got me stumped.
>
> Anyone got an example line of code to help me out?
>
> I can't seem to find the answer in the help docs.
>
> Would greatly appreciate any/ all help;-)
> mikeB
>

You don't really have a ListView but a ColumnView, do you? A ColumnView is
a ColumnView and not "a Listview (set as Column view)". The ListView control
doesn't have a Columns property.

I have to say that when I tried to answer your question, I noticed that
I had no clue how ListView, its sibling ColumnView or their mutual parent
_TreeView work, so I read their source code (see gb.gui.base) -- and I
still had no clue. And let me say that this happens rarely to me these days.
I had to dig up an example (the FileView class in gb.form is very nice)
to see what they actually do with their columns. Since I get it now, I want
to give an explanation of these classes first, so bear with me.

To understand ColumnView you have to understand _TreeView, because
ColumnView is basically a _TreeView with some code added to manage columns,
but the columns are already available from _TreeView.

To add to the confusion, a _TreeView is internally basically a GridView,
i.e. a square grid of cells in which you can put strings and pictures,
but you can't access these cells /that/ freely from a _TreeView. The key
information is that each _TreeView item is an entire *row* in the GridView.

By calling ColumnView.Add("1", "First var entry") you create a new row
in the GridView, identified by the key "1", and set the text of the first
column of that row to "First var entry". The return value of the Add()
method is a _TreeView_Item object which allows you to set the texts of
all other columns:

  ColumnView.Add("1", "First var entry")[1] = "second column"

Wrap it in a With or store it in a variable if you want to set many other
columns:

  Dim hItem As _TreeView_Item

  hItem = ColumnView.Add("1", "First var entry")
  hItem[1] = "second column"
  hItem[2] = "third column"

The asymmetric treatment of the first vs. the other columns is most likely
because you always want to set at least the first column's text, and maybe
of technical nature as the Add() method has optional parameters which make
it uglier to add a variable argument list (Param in gb) to Add().

Regards,
Tobi

--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help with ListView code?

mikeB-2
Greetings,

I just want to give a BIG THANK YOU to all those that responded to help

me solve this problem - special gratitude goes out to 'Tobias Boege'

for his time and efforts to give me a better picture of whats going

on with the "ColunmView" control. I've still got a few problems to solve

but at least I now have what I might need to solve them;-)


Without you experienced Gambas coders offering your time and knowledge =

I don't see how any "newbie', to the language, would get much done -
cuz, while

it's true "Gambas is Almost Basic" there's a lot of difference (as you
all know).

I will publish the new Gambas GNU app I am writing so that other
"newbies" might

have a better time of using this control (Learn by Example).


THANKS AGAIN and HAVE A GREAT DAY,

mikeB



On 07/28/2017 07:47 AM, Tobias Boege wrote:

> On Thu, 27 Jul 2017, mikeB wrote:
>> Greetings all,
>> I've got a Listview (set as Column view) with 2 columns that I'm using
>>
>> for testing so I might understand how all this works so can add it to a
>> project.
>>
>> testCode..................................................
>> With listview1
>>      .Clear
>>      .Resizable = True
>>      .Columns.Count = 2
>>      .Columns[0].Text = "Site Name:"
>>      .Columns[1].Text = "Site URL:"
>> End With
>> ..................................................................
>> I can add values to the 1st column:
>> code..........................................................
>> listview1.add("1", "First var entry")
>> listview1.add("2", "Second var entry to test the resize ability")
>> listview1.add("3", "Third var entry")
>> ...................................................................
>> Have spent a lot of research time trying to figure out how to add
>> values to the 2nd column (Site URL:) - got me stumped.
>>
>> Anyone got an example line of code to help me out?
>>
>> I can't seem to find the answer in the help docs.
>>
>> Would greatly appreciate any/ all help;-)
>> mikeB
>>
> You don't really have a ListView but a ColumnView, do you? A ColumnView is
> a ColumnView and not "a Listview (set as Column view)". The ListView control
> doesn't have a Columns property.
>
> I have to say that when I tried to answer your question, I noticed that
> I had no clue how ListView, its sibling ColumnView or their mutual parent
> _TreeView work, so I read their source code (see gb.gui.base) -- and I
> still had no clue. And let me say that this happens rarely to me these days.
> I had to dig up an example (the FileView class in gb.form is very nice)
> to see what they actually do with their columns. Since I get it now, I want
> to give an explanation of these classes first, so bear with me.
>
> To understand ColumnView you have to understand _TreeView, because
> ColumnView is basically a _TreeView with some code added to manage columns,
> but the columns are already available from _TreeView.
>
> To add to the confusion, a _TreeView is internally basically a GridView,
> i.e. a square grid of cells in which you can put strings and pictures,
> but you can't access these cells /that/ freely from a _TreeView. The key
> information is that each _TreeView item is an entire *row* in the GridView.
>
> By calling ColumnView.Add("1", "First var entry") you create a new row
> in the GridView, identified by the key "1", and set the text of the first
> column of that row to "First var entry". The return value of the Add()
> method is a _TreeView_Item object which allows you to set the texts of
> all other columns:
>
>    ColumnView.Add("1", "First var entry")[1] = "second column"
>
> Wrap it in a With or store it in a variable if you want to set many other
> columns:
>
>    Dim hItem As _TreeView_Item
>
>    hItem = ColumnView.Add("1", "First var entry")
>    hItem[1] = "second column"
>    hItem[2] = "third column"
>
> The asymmetric treatment of the first vs. the other columns is most likely
> because you always want to set at least the first column's text, and maybe
> of technical nature as the Add() method has optional parameters which make
> it uglier to add a variable argument list (Param in gb) to Add().
>
> Regards,
> Tobi
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Loading...