• Viernes 26 de Abril de 2024, 09:42

Autor Tema:  Insertar Datos....  (Leído 1669 veces)

Taursoft

  • Miembro activo
  • **
  • Mensajes: 27
    • Ver Perfil
Insertar Datos....
« en: Miércoles 14 de Enero de 2004, 15:52 »
0
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

  • Miembro de PLATA
  • *****
  • Mensajes: 1058
    • Ver Perfil
Re: Insertar Datos....
« Respuesta #1 en: Jueves 15 de Enero de 2004, 15:04 »
0
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
  1.  
  2.     ListView1.ColumnHeaders.Add , , "Nombre"
  3.     ListView1.ColumnHeaders.Add , , "Género"
  4.     ListView1.ColumnHeaders.Add , , "Idioma"
  5.     ListView1.ColumnHeaders.Add , , "Soporte"
  6.     ListView1.ColumnHeaders.Add , , "S.O."
  7.  
  8.  

2 - Obtener las secciones que hay en el archivo (que aparenta tener la estructura de un archivo INI).

Código: Text
  1.  
  2.      .
  3.      .
  4.      .
  5.     On Error GoTo Err_Open
  6.     Dim intCanal As Integer
  7.     intCanal = FreeFile
  8.     Open "C:\Ruta\ArchivoATratar.xxx" For Input As #intCanal
  9.     Dim str1 As String, int1 As Integer
  10.     Dim AppNames() As String
  11.     Do Until EOF(intCanal)
  12.         Line Input #intCanal, str1
  13.         str1 = Trim(str1)
  14.         If Left(str1, 1) = "[" And Right(str1, 1) = "]" Then
  15.             int1 = int1 + 1
  16.             ReDim Preserve AppNames(1 To int1)
  17.             AppNames(int1) = Mid(str1, 2, Len(str1) - 2)
  18.         End If
  19.     Loop
  20.     .
  21.     .
  22.     .
  23. Err_Open:
  24.     On Local Error Resume Next
  25.     Close #intCanal
  26.     .
  27.     -
  28.     -
  29.  
  30.  

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
  1.  
  2.     .
  3.     .
  4.     .
  5.     On Error Resume Next
  6.  
  7.     Dim int1 As Integer
  8.     int1 = UBound(AppNames)
  9.     If int1 = 0 Then Exit Sub
  10.    
  11.     Dim str1 As String, int2 As Integer
  12.     For int1 = 1 To UBound(AppNames)
  13.        
  14.         str1 = String(255, " ")
  15.         str1 = GetPrivateProfileString( _
  16.         AppNames(int1), "1", "x", str1, 255, _
  17.         "C:\Ruta\ArchivoATratar.xxx")
  18.         ListView1.ListItems.Add , , Replace(str1, Chr(0), "")
  19.        
  20.         For int2 = 1 To 3
  21.             str1 = String(255, " ")
  22.             str1 = GetPrivateProfileString( _
  23.             AppNames(int1), CStr(int2 + 1), "x", str1, _
  24.             255, "C:\MiRuta\ArchivoATratar.xxx")
  25.             ListView1.ListItems( _
  26.             ListView1.ListItems.Count).SubItems(int2) _
  27.             = Replace(str1, Chr(0), "")
  28.         Next int2
  29.        
  30.     Next int1
  31.     .
  32.     .
  33.     .
  34.  
  35.  

Y ya está...
Abur.

Taursoft

  • Miembro activo
  • **
  • Mensajes: 27
    • Ver Perfil
Re: Insertar Datos....
« Respuesta #2 en: Jueves 15 de Enero de 2004, 15:43 »
0
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

  • Miembro activo
  • **
  • Mensajes: 27
    • Ver Perfil
Re: Insertar Datos....
« Respuesta #3 en: Jueves 15 de Enero de 2004, 15:54 »
0
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
El mensaje contiene 1 archivo adjunto. Debes ingresar o registrarte para poder verlo y descargarlo.

Brroz

  • Miembro de PLATA
  • *****
  • Mensajes: 1058
    • Ver Perfil
Re: Insertar Datos....
« Respuesta #4 en: Jueves 15 de Enero de 2004, 16:15 »
0
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

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?

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

Suerte.

Taursoft

  • Miembro activo
  • **
  • Mensajes: 27
    • Ver Perfil
Re: Insertar Datos....
« Respuesta #5 en: Jueves 15 de Enero de 2004, 16:34 »
0
Y TU SABRIAS CUAL ES EL CONTROL DE LA IMAGEN QUE TE MANDO.
ES UN DATAGRID O ES UN LISTVIEW O OTRO DISTINTO?
GRACIAS Y SALUDOS
SEGURAMENTE UTILICE LO QUE ME DIGISTE DE LOS ARCHIVOS INI