Visual Basic - AYUDA CON EL LISTBOX...

Life is soft - evento anual de software empresarial
 
Vista:

AYUDA CON EL LISTBOX...

Publicado por Fran (23 intervenciones) el 28/09/2000 00:00:00
Gracias por Leer mi Pregunta..
Mi problema es que quisiera que los compentes que hay insertado en un listbox quiero que esten alineados a la derecha y no a la Izquierda...

¿¿¿¿¿¿ COMO SE HACE ?????

Muchas Gracias...
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:AYUDA CON EL LISTBOX...

Publicado por tecniCam (220 intervenciones) el 28/09/2000 00:00:00
¡MIRA LO QUE TENÍA GUARDADO POR AHÍ! Nunca lo he probado, ni me acuerdo de dónde lo saqué:
DICE LO SIGUIENTE:

¿Cómo alinear los contenidos de un ListBox a la derecha?:
Para conseguir este efecto es necesario usar inteligentemente el tabulador ( Chr$(9) ) y una
llamadita a la "indispensable", o sea, a SendMessage (leed mi artículo de Junio en la revista
RPP (Revista Profesional para Programadores) para encontrar una buena introducción a su
uso) .
De todas formas este truco está sacado directamente de la Knowledge Base de Visual Basic,
concretamente del artículo Q110958 y por mi eterna falta de tiempo no me he parado a
probarlo siquiera, pero claro, viniendo de la KB tiene que funcionar perfectamente.

A continuación reproduzco exactamente lo que ponía la KB:
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for
Windows, version 3.0
SUMMARY
The sample program below shows how to right justify items in a list box.

MORE INFORMATION
This program calls the SendMessage Windows API function to set a tab stop at every character
position in the list box. The program prefixes the appropriate number of tabs to right justify each string
in the list box. You need to set the maximum allowed string length in the program.

Step-by-Step Example
1. Start a new project in Visual Basic. Form1 is created by default.
2. Add a large list box (List1) to Form1.
3. Add the following to the Form Load event code:

Sub Form_Load ()
Const WM_USER = &H400
Const LB_SETTABSTOPS = WM_USER + 19
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE: II AYUDA CON EL LISTBOX...

Publicado por tecniCam (220 intervenciones) el 28/09/2000 00:00:00
Const maxlen = 10 ´ Maximum expected string length in list box.
tabchar = Chr$(9) ´ ASCII code for a tab
ReDim a$(maxlen) ´ String array to right justify in list box.
form1.Show ´ Must Show form in Load event before Print
´ will become visible.
´ GetDialogBaseUnits() API function lets you calculate the average
´ width of characters in the system font.
bu& = GetDialogBaseUnits()
hiword = bu& \ (2 ^ 16) ´ 16 pixels high in default system font
loword = bu& And &HFFFF& ´ 8 pixels wide in default system font.
Print "System font width and height, in pixels: " & loword, hiword
´Assign the array of defined tab stops.
Static tabs(1 To maxlen) As Integer
For j = 1 To maxlen ´ Set tabs every 4 dialog units (one character):
tabs(j) = (loword * j) / 2
´ On most Windows systems, you need only this: tabs(j) = j * 4
Next
´Send message to the List1 control through the Windows message queue:
retVal& = SendMessage(List1.hWnd, LB_SETTABSTOPS, maxlen, tabs(1))
For j = 1 To maxlen
a$(j) = String$(j, "a") ´ Assign an arbitrary character string.
´ Add the appropriate number of tabstops to right justify:
tabstring = String$(maxlen + 1 - Len(a$(j)), Chr$(9))
List1.AddItem tabstring & a$(j)
Next
End Sub

4. Add the following Windows API declarations to the General Declarations section:
Declare Function GetDialogBaseUnits Lib
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE: y III AYUDA CON EL LISTBOX...

Publicado por tecniCam (220 intervenciones) el 28/09/2000 00:00:00
4. Add the following Windows API declarations to the General Declarations section:
Declare Function GetDialogBaseUnits Lib "User" () As Long
´ Enter the following Declare statement on one, single line:
Declare Function SendMessage Lib "user" (ByVal hWnd As Integer, ByVal wMsg As Integer, _
ByVal wp As Integer, lp As Any) As Long
5. Start the program, or press the F5 key. All strings are right-justified
in the list box. Close the form to end the program.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 27
Ha aumentado su posición en 53 puestos en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

RE: y III AYUDA CON EL LISTBOX...

Publicado por EL FER (13 intervenciones) el 04/07/2021 18:18:17
prueba

amigos hola quisiera saber si alguien me puede ayudar con este dato tengo varias columnas en el listbox pero me salen los precios movidos como podria establecer su posicion para que me queden tabulados y tambien poder realizar la suma de toda la columna total y que me vaya sumando en el textbox de total a pagar gracias por la ayuda
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 145
Ha aumentado 1 puesto en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

RE: y III AYUDA CON EL LISTBOX...

Publicado por Sah1d Ra (191 intervenciones) el 06/07/2021 17:13:30
utiliza vbtab e vez de espacios
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 27
Ha aumentado su posición en 53 puestos en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

RE: y III AYUDA CON EL LISTBOX...

Publicado por EL FER (13 intervenciones) el 07/07/2021 19:24:47
ya lo realice pero me sigue moviendo los precios
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar