Programación General > Visual Basic 6.0 e inferiores

 Insertar Datos....

(1/2) > >>

Taursoft:
HOLA A TODOS MIRAD NECESITO SI ALGUIEN LO SABE Y CLARO ESTA NO LE IMPORTA EXPLICARMELO QUE ME DIGAN COMO PUEDO PONER DATOS EN UN DATAGRID O EN UN LISTVIEW DESDE UN ARCHIVO DE TEXTO CON LA SIGUIENTE EXTRUCTURA:
[Bird Hunter 2003]
1=Caza
2=Ingles
3=CD
4=Windows 95/98/ME/NT/2000/XP

[Deer Hunter 2004]
1=Caza
2=Ingles
3=CD
4=Windows 95/98/ME/NT/2000/XP

LO QUE QUIERO ES QUE EN EL DATAGRID ME PONGA EN UNA COLUMNA LLAMADA "NOMBRE" LOS DATOS QUE APARECEN EN CORCHETE LUEGO EN OTRA COLUMNA LOS DATOS QUE APARECEN NUMERADOS.

EJEMPLO:

NOMBRE                  |GENERO    |IDIOMA    |SOPORTE   |S.O
Bird Hunter 2003      |Caza         |Ingles      |CD             |Windows....

ESPERO ME PODAIS DECIR COMO SE HACE YA QUE ESTOY EMPEZANDO Y ME GUSTARIA APRENDER A HACER ESTO.

UN SALUDO A TODOS

Brroz:
Hola TaurSoft.

Los pasos que podrías seguir son estos:

1 - Añadir los encabezados de columna (que sabes cuales son de antemano) al ListView.


--- Código: Text ---     ListView1.ColumnHeaders.Add , , "Nombre"    ListView1.ColumnHeaders.Add , , "Género"    ListView1.ColumnHeaders.Add , , "Idioma"    ListView1.ColumnHeaders.Add , , "Soporte"    ListView1.ColumnHeaders.Add , , "S.O."  
2 - Obtener las secciones que hay en el archivo (que aparenta tener la estructura de un archivo INI).


--- Código: Text ---      .     .     .    On Error GoTo Err_Open    Dim intCanal As Integer    intCanal = FreeFile    Open "C:\Ruta\ArchivoATratar.xxx" For Input As #intCanal    Dim str1 As String, int1 As Integer    Dim AppNames() As String    Do Until EOF(intCanal)        Line Input #intCanal, str1        str1 = Trim(str1)        If Left(str1, 1) = "[" And Right(str1, 1) = "]" Then            int1 = int1 + 1            ReDim Preserve AppNames(1 To int1)            AppNames(int1) = Mid(str1, 2, Len(str1) - 2)        End If    Loop    .    .    .Err_Open:    On Local Error Resume Next    Close #intCanal    .    -    -  
Con esto tengo en la matriz AppNames las supuestas secciones del archivo.

3 - Ir añadiendo ListItems al ListView a medida que leemos el valor de cada clave de cada sección.


--- Código: Text ---     .    .    .    On Error Resume Next     Dim int1 As Integer    int1 = UBound(AppNames)    If int1 = 0 Then Exit Sub        Dim str1 As String, int2 As Integer    For int1 = 1 To UBound(AppNames)                str1 = String(255, " ")        str1 = GetPrivateProfileString( _        AppNames(int1), "1", "x", str1, 255, _        "C:\Ruta\ArchivoATratar.xxx")        ListView1.ListItems.Add , , Replace(str1, Chr(0), "")                For int2 = 1 To 3            str1 = String(255, " ")            str1 = GetPrivateProfileString( _            AppNames(int1), CStr(int2 + 1), "x", str1, _            255, "C:\MiRuta\ArchivoATratar.xxx")            ListView1.ListItems( _            ListView1.ListItems.Count).SubItems(int2) _            = Replace(str1, Chr(0), "")        Next int2            Next int1    .    .    .  
Y ya está...
Abur.

Taursoft:
UNAS PREGUNTAS PUEDO AÑADIR DATOS A UN LISTVIEW EN EJECUCIÓN?
Y PUEDO AÑADIR O QUITAR ENCABEZADOS?
PODRÍA HACER ESO QUE ME DICES CON UN DATAGRID?
Y SE PUEDE PINTAR LAS FILAS DE UN LISTVIEW DE COLORES DISTINTOS?
MUCHAS GRACIAS DE ANTEMANO POR AYUDARME.
SALUDOS

Taursoft:
MIRA TE MADO UNA CAPTURA DE LO QUE QUIERO HACER Y EL ARCHIVO CON LA ESTRUCTURA QUE QUIERO QUE LEA Y ME ACONSEJAS COMO LO HAGO.
VALE?

SALUDOS

Brroz:

--- Citar ---UNAS PREGUNTAS PUEDO AÑADIR DATOS A UN LISTVIEW EN EJECUCIÓN?
Y PUEDO AÑADIR O QUITAR ENCABEZADOS?
PODRÍA HACER ESO QUE ME DICES CON UN DATAGRID?
Y SE PUEDE PINTAR LAS FILAS DE UN LISTVIEW DE COLORES DISTINTOS?
MUCHAS GRACIAS DE ANTEMANO POR AYUDARME.
SALUDOS

--- Fin de la cita ---

Las respuesta son:

1 - SÍ
2 - SÍ
3 - ¿POR QUÉ NO?
4 - SEGURAMENTE, peeeero: esto yo sólo lo sabría hacer empleando unas triquiñuelas: usar subclasificación (que mejor casi que no) o añadir una imagen de fondo al listview 'con los colores de las filas pintadas'...


--- Citar ---MIRA TE MADO UNA CAPTURA DE LO QUE QUIERO HACER Y EL ARCHIVO CON LA ESTRUCTURA QUE QUIERO QUE LEA Y ME ACONSEJAS COMO LO HAGO.
VALE?

--- Fin de la cita ---

Ya te he dicho como lo haría yo... ahora, tu verás.

Suerte.

Navegación

[0] Índice de Mensajes

[#] Página Siguiente

Ir a la versión completa