Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2835 connectés 

 


Dernière réponse
Sujet : [VB] : ListBox : changer l'aspect de la police (couleur / gras ...)
Carbon_14 Sous VB3 (celui auquel je suis resté), cela n'était pas possible. Par contre, un article Crosoft de l'époque :
 
VB 3: Display Multiple Foreground Text Colors in VB List Box
Article ID: Q108811
------------------------------------------------------------
The information in this article applies to:
 
- Standard and Professional Editions of Microsoft Visual Basic for Windows, version 3.0
---------------------------------------------------------------------
 
SUMMARY
=======
 
To set the foreground and background color of a list box control, set the ForeColor and BackColor properties at either design time or run time. All text in a list box uses the color set by the ForeColor property. The text is printed against a background color set by the BackColor property.
 
Visual Basic doesn't directly support the display of text of different colors simultaneously in the list box. This article describes how to display words of different colors simultaneously in a list box by using an indirect technique.
 
MORE INFORMATION
================
 
You can display lines or words of different colors simultaneously in a List box by using one of the following indirect techniques.
 
1. Simulate the list box with a picture box control. You can store the desired text strings in an array of strings, and use the Print method to write the array entries into the picture box with different ForeColor properties. For example:
      picture1.BackColor = QBColor(14)  ' 14=Light yellow
      picture1.ForeColor = QBColor(4)   '  4=Red
      picture1.Print "in living red"
      picture1.ForeColor = QBColor(2)   '  2=Green
      picture1.Print "in living green"
 
   You can also add a vertical scroll bar next to the picture box. When the scroll bar is scrolled, your code needs to redraw the picture box. The ForeColor property of the picture box controls the current color used by the Print method. The picture box will not let you highlight text.
 
   NOTE: The BackColor method erases any pre-existing text on the picture control.
 
2. For coloring list box entries with multiple foreground colors, the Desaware company provides two solutions:
 
   a. The MLIST2.VBX control file is included with the Custom Control ... etc etc.. mais c'est commercial (!!).

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
Carbon_14 Sous VB3 (celui auquel je suis resté), cela n'était pas possible. Par contre, un article Crosoft de l'époque :
 
VB 3: Display Multiple Foreground Text Colors in VB List Box
Article ID: Q108811
------------------------------------------------------------
The information in this article applies to:
 
- Standard and Professional Editions of Microsoft Visual Basic for Windows, version 3.0
---------------------------------------------------------------------
 
SUMMARY
=======
 
To set the foreground and background color of a list box control, set the ForeColor and BackColor properties at either design time or run time. All text in a list box uses the color set by the ForeColor property. The text is printed against a background color set by the BackColor property.
 
Visual Basic doesn't directly support the display of text of different colors simultaneously in the list box. This article describes how to display words of different colors simultaneously in a list box by using an indirect technique.
 
MORE INFORMATION
================
 
You can display lines or words of different colors simultaneously in a List box by using one of the following indirect techniques.
 
1. Simulate the list box with a picture box control. You can store the desired text strings in an array of strings, and use the Print method to write the array entries into the picture box with different ForeColor properties. For example:
      picture1.BackColor = QBColor(14)  ' 14=Light yellow
      picture1.ForeColor = QBColor(4)   '  4=Red
      picture1.Print "in living red"
      picture1.ForeColor = QBColor(2)   '  2=Green
      picture1.Print "in living green"
 
   You can also add a vertical scroll bar next to the picture box. When the scroll bar is scrolled, your code needs to redraw the picture box. The ForeColor property of the picture box controls the current color used by the Print method. The picture box will not let you highlight text.
 
   NOTE: The BackColor method erases any pre-existing text on the picture control.
 
2. For coloring list box entries with multiple foreground colors, the Desaware company provides two solutions:
 
   a. The MLIST2.VBX control file is included with the Custom Control ... etc etc.. mais c'est commercial (!!).
HelloWorld ben vi j'ai tenté ... mais apres le list1.list(1), si je met un point j'ai aucune propriete ki s'affiche ...
Ciler Tu as essayé list1.list(<n° d'index> ).<code de police> ?
Ca marche peut être ?
HelloWorld je voudrais changer la couleur et/ou mettre en gras une (1) ligne en particulier, et que elle, et pas les autres ...
le but est de facilement retrouver un élément dans une listbox, il me faut un moyen de le mettre en évidence (l'ideal serait de le mettre en rouge, mais en gras ce serait deja cool ;))
j'ai cherché et j'ai rien trouvé ... :(

Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)