Add multiple properties to ListView1

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
User avatar
gambafeliz
Posts: 141
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

Add multiple properties to ListView1

Post by gambafeliz »

I have this line that works:

ListView1.Add(resultado["ID"], resultado["Name"], Picture[$sNoMonitor]).Foreground = Color.RGB(255, 0, 125) 
' ListView1.Add(resultado["ID"], resultado["Name"], Picture[$sNoMonitor]).RichText = "<b style='color:rgb(255,0,125);'>" & resultado["Nombre"] & "</b>"  (This works but I don't want to do it like this)


But I want to add .Font.Bold = True but how would it be done if possible.

Thank you.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
User avatar
gambafeliz
Posts: 141
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

Re: Add multiple properties to ListView1

Post by gambafeliz »

My solution:

               With ListView1
                  .Add(resultado["ID"], resultado["Name"], Picture[$sNoMonitor])
                  .Foreground = Color.RGB(255, 0, 125) '.RichText = "<b style='color:rgb(255,0,125);'>" & resultado["Nombre"] & "</b>"
                  .Font.Bold = True
               End With  


Note: (This solution does not work for the individual addition therefore it is not a valid solution. It is valid for all items)
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
User avatar
BruceSteers
Posts: 1579
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Add multiple properties to ListView1

Post by BruceSteers »

gambafeliz wrote: Tuesday 7th November 2023 7:41am My solution:

               With ListView1
                  .Add(resultado["ID"], resultado["Name"], Picture[$sNoMonitor])
                  .Foreground = Color.RGB(255, 0, 125) '.RichText = "<b style='color:rgb(255,0,125);'>" & resultado["Nombre"] & "</b>"
                  .Font.Bold = True
               End With  


Note: (This solution does not work for the individual addition therefore it is not a valid solution. It is valid for all items)
You're pretty close...
If you mix your 2 solutions together you will get this...

               With ListView1.Add(resultado["ID"], resultado["Name"], Picture[$sNoMonitor])
                  .Foreground = Color.RGB(255, 0, 125) '.RichText = "<b style='color:rgb(255,0,125);'>" & resultado["Nombre"] & "</b>"
                  .Font.Bold = True
               End With  
If at first you don't succeed , try doing something differently.
BruceS
User avatar
gambafeliz
Posts: 141
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

Re: Add multiple properties to ListView1

Post by gambafeliz »

Thank you very much for your always effort. Thank you.

With ListView1.Add(resultado["ID"], resultado["Name"], Picture[$sNoMonitor])
   .Foreground = Color.RGB(255, 0, 125) '.RichText = "<b style='color:rgb(255,0,125);'>" & resultado["Nombre"] & "</b>"
   .Font.Bold = True 'Here
End With 


But right on the line that I indicated, the Subroutine is exited. As if an error occurred. I don't know what's happening yet. But this gives an error, when I do what you tell me, in fact I already tried it but since it failed me, I have left it, because it is impossible for the moment.

Note: Error.Code = 13 = Null object
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
User avatar
BruceSteers
Posts: 1579
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Add multiple properties to ListView1

Post by BruceSteers »

gambafeliz wrote: Tuesday 7th November 2023 11:26am Thank you very much for your always effort. Thank you.

With ListView1.Add(resultado["ID"], resultado["Name"], Picture[$sNoMonitor])
   .Foreground = Color.RGB(255, 0, 125) '.RichText = "<b style='color:rgb(255,0,125);'>" & resultado["Nombre"] & "</b>"
   .Font.Bold = True 'Here
End With 


But right on the line that I indicated, the Subroutine is exited. As if an error occurred. I don't know what's happening yet. But this gives an error, when I do what you tell me, in fact I already tried it but since it failed me, I have left it, because it is impossible for the moment.

Note: Error.Code = 13 = Null object
You are correct, the .Font property does not seem to be initialized , so accessing it's .Bold property throws an error.

So this works...
With ListView1.Add(resultado["ID"], resultado["Name"], Picture[$sNoMonitor])
   .Foreground = Color.RGB(255, 0, 125) '.RichText = "<b style='color:rgb(255,0,125);'>" & resultado["Nombre"] & "</b>"
   .Font = ListView1.Font  ' initalize the Font property
   .Font.Bold = True '  okay now
End With 
If at first you don't succeed , try doing something differently.
BruceS
User avatar
gambafeliz
Posts: 141
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

Re: Add multiple properties to ListView1

Post by gambafeliz »

Thanks, it works perfectly.
You do know about Gambas programming.

That's if I painted the wall in my living room, maybe I wouldn't call you. :)
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Post Reply