CSPromex
¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.


Programadores dedicados a C sharp .Net, eres nuevo, experto o quieres aprender a programar en C Sharp, aquí encontraras todo lo que necesitas.
 
ÍndiceBuscarÚltimas imágenesChatRegistrarseConectarse
Conectarse
Nombre de Usuario:
Contraseña:
Entrar automáticamente en cada visita: 
:: Recuperar mi contraseña
Últimos temas
» Sockets Conexion,Envio y recepcion de datos (mini-chat Cliente-Servidor)
Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeSáb Sep 30, 2023 6:24 pm por EurekaMartin

» Graficos: Grafica circular
Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeMar Mar 05, 2019 4:58 pm por Luis Garcia

» Calendario hecho Manualmente
Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeMar Mar 05, 2019 3:52 pm por Luis Garcia

» Activar el protector de pantalla.
Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeMar Mar 05, 2019 3:12 pm por Luis Garcia

» Hacer backup de MySql desde C#
Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeMar Abr 18, 2017 10:04 pm por maurifl

» Sockets programa para Ciber Cafe (Cliente-Servidor)
Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeLun Ago 10, 2015 5:45 pm por artes

» Ayuda crear emoticones en un chat
Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeDom Jul 12, 2015 9:00 pm por yeco96

» Necesito ayuda para pasar datos a un Datagridview
Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeDom Jun 07, 2015 4:33 pm por rafaelfa

» Reproductor de música->Lista de reproducción (Guardar-Cargar)
Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeLun Jun 01, 2015 3:00 pm por kevin22

Buscar
 
 

Resultados por:
 
Rechercher Búsqueda avanzada
Síguenos:
Crear foro Crear foro Crear foro

 

 Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional

Ir abajo 
2 participantes
AutorMensaje
Cinder92
Programador Intermedio
Cinder92


Mensajes : 29
Puntos : 52

Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional Empty
MensajeTema: Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional   Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeSáb Abr 02, 2011 12:33 am

Hola que tal quisiera saber como agregar datos desde un textbox a un vector o arreglo unidireccional el codigo que tengo es el siguiente

Código:


using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Maestros.DAO;
using Maestros.BO;

namespace Maestros
{
   /// <summary>
   /// Description of MainForm.
   /// </summary>
   public partial class MainForm : Form
   {
      
      public int[] Maestro = new int[30];
      Maestro oMaestro = new Maestro();
      MaestroDAO oMaestroDAO = new MaestroDAO();
      
      public MainForm()
      {
         InitializeComponent();
      }
      
      void Button3Click(object sender, EventArgs e)
      {
         Application.Exit();
      }
      
      void Button1Click(object sender, EventArgs e)
      {

            oMaestro.Matricula = Convert.ToInt32(txtmatricula.Text);
            oMaestroDAO.Agregar = oMaestro.Matricula;
            oMaestro.Nombre = txtnombre.Text;
            oMaestro.Direccion = txtdir.Text;
            oMaestro.Fecha_Nac = txtfecha.Text;
            oMaestro.Sueldo = Convert.ToDouble(txtsueldo.Text);
            oMaestro.Correo = txtcorreo.Text;
            oMaestro.Telefono = txttel.Text;
            Maestro[oMaestroDAO.Agregar] = Convert.ToInt32(oMaestro);
         
      }
      
      void Button5Click(object sender, EventArgs e)
      {
         MessageBox.Show(Convert.ToString(Maestro[oMaestroDAO.Listar]));
      }
   }
}

pero me marca error en que no se puede convertir un tipo de objeto

les agradezco su amable atencion gracias esto es en windows form
Volver arriba Ir abajo
Guillermo Javier Salazar
STAFF TEAM
STAFF TEAM
Guillermo Javier Salazar


Mensajes : 181
Puntos : 349
Localización : México
Comentarios : El azar favorece a una mente preparada.

Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional Empty
MensajeTema: Re: Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional   Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeSáb Abr 02, 2011 5:59 am

Cinder92, Te recuerdo que el foro de "Código abierto" es solo para publicar códigos, si vas a realizar una petición o tienes alguna duda para eso esta el foro de "Foro de ayuda".

Tema movido.
Volver arriba Ir abajo
https://cspromex.activo.mx
Guillermo Javier Salazar
STAFF TEAM
STAFF TEAM
Guillermo Javier Salazar


Mensajes : 181
Puntos : 349
Localización : México
Comentarios : El azar favorece a una mente preparada.

Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional Empty
MensajeTema: Re: Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional   Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeSáb Abr 02, 2011 6:09 am

Tu error radica en que tu vector es de tipo int y quieres guardar un objeto de tipo "Maestro", Al realizar la conversión "Convert.ToInt32(oMaestro);" marca ese error a causa de que no se puede realizar la conversión.

Si deseas guardar el objetos de tipo "Maestro" en un vector, el vector debe de ser del mismo tipo:

Maestro[] Maestro = new Maestro[];

Ahora si podrás guardar el objeto, sin tener que realizar una conversión antes:

Maestro[oMaestroDAO.Agregar] = oMaestro;

Saludos!!
Volver arriba Ir abajo
https://cspromex.activo.mx
Cinder92
Programador Intermedio
Cinder92


Mensajes : 29
Puntos : 52

Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional Empty
MensajeTema: Re: Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional   Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitimeSáb Abr 02, 2011 9:58 am

ok lo hice, pasa que a la hora de agregar los datos en la cadena

Código:
Maestro[oMaestroDAO.Agregar] = oMaestro;

Me dice que esta fuera de los limites de la cadena intente agregarle el rango pero no funciona. gracias

Edito

Pude hacer que funcione

pero le mando un metodo que me liste lo que hay en ese rango y no muestra nada

Código:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Maestros.DAO;
using Maestros.BO;

namespace Maestros
{
   /// <summary>
   /// Description of MainForm.
   /// </summary>
   public partial class MainForm : Form
   {
      
      public Maestro[] Maestro = new Maestro[30];
      Maestro oMaestro = new Maestro();
      MaestroDAO oMaestroDAO = new MaestroDAO();
      
      public MainForm()
      {
         InitializeComponent();
      }
      
      void Button3Click(object sender, EventArgs e)
      {
         Application.Exit();
      }
      
      void Button1Click(object sender, EventArgs e)
      {

                oMaestro.Matricula = Convert.ToInt32(txtmatricula.Text);
                oMaestroDAO.Agregar = oMaestro.Matricula;
                oMaestro.Nombre = txtnombre.Text;
                oMaestro.Direccion = txtdir.Text;
                oMaestro.Fecha_Nac = txtfecha.Text;
                oMaestro.Sueldo = Convert.ToDouble(txtsueldo.Text);
                oMaestro.Correo = txtcorreo.Text;
                oMaestro.Telefono = txttel.Text;
                Maestro[oMaestroDAO.Agregar] = Maestro[0];

         
      }
      
      void Button5Click(object sender, EventArgs e)
      {
         MessageBox.Show(Convert.ToString(Maestro[0]));
      }
   }
}


cabe destacar que los metodos agregar, modificar, eliminar, buscar y listar son de tipo int y solo tienen metodos get y set
Volver arriba Ir abajo
Contenido patrocinado





Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional Empty
MensajeTema: Re: Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional   Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional I_icon_minitime

Volver arriba Ir abajo
 
Ayuda Insertar datos desde un textbox a un vector o arreglo unidireccional
Volver arriba 
Página 1 de 1.
 Temas similares
-
» insertar datos de datagridview y textbox al mismo tiempo C# SQL server
» Manejo de Arreglo de Byte[]
» como pasar los datos de los textbox a un datagrid
» Novato en C# ayuda con Bases de Datos
» Necesito ayuda para pasar datos a un Datagridview

Permisos de este foro:No puedes responder a temas en este foro.
CSPromex :: PROGRAMACIÓN EN C# :: Foro de ayuda-
Cambiar a: