469,142 Members | 1,089 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,142 developers. It's quick & easy.

cannot convert System.Windows.Controls.ComboBox to System.Window.Forms

I need to execute display a list of values in a combo box of a database of acesss

Expand|Select|Wrap|Line Numbers
  1.   private void paises_Loaded(object sender, RoutedEventArgs e)
  2.         {
  3.             claDatos datos = new claDatos();
  4.             datos.LLenarCombo(pairses, "SELECT * FROM Tabla_Pais", "PAIS", "CODIGO");
  5.         }
but when i try to run it , it get this error cannot convert System.Windows.Controls.ComboBox to System.Window.Forms

there is someone who can help me

the class does not have mistake


and i call with a class
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Data;
  3. using System.Data.OleDb;
  4. using System.Windows.Forms;
  5.  
  6. namespace CRACKK
  7. {
  8.     public class claDatos
  9.     {
  10.  
  11.         OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\NET\CRACKK\FrontEndEnroll\CRACKK\Storage\DB\Datos.accdb");
  12.  
  13.         public DataTable Consulta(string strSql)
  14.         {
  15.  
  16.             DataTable dt = new DataTable();
  17.             OleDbDataAdapter da = new OleDbDataAdapter(strSql, conn);
  18.             da.Fill(dt);
  19.             return dt;
  20.  
  21.         }
  22.  
  23.         public void LLenarCombo(ComboBox combo, string strSql, string codigo, string descripcion)
  24.         {
  25.  
  26.             DataTable tabla = new DataTable();
  27.             OleDbDataAdapter da = new OleDbDataAdapter();
  28.             da.SelectCommand = new OleDbCommand(strSql, conn);
  29.             da.Fill(tabla);
  30.             combo.ValueMember = codigo;
  31.             combo.DisplayMember = descripcion;
  32.             combo.DataSource = tabla;
  33.         }
  34.     }
  35. }
3 Weeks Ago #1
1 4437
GazMathias
202 Expert 128KB
Hi.

Its not clear if the error you are experiencing is thrown inside of the code you have posted or not so I recommend that you add a break point and step through from the LLenarCombo call and verifty that you are passing the object you suspect.

Additionally, shouldn't the combo box be passed by reference?

Gaz
2 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by =?Utf-8?B?WmlnZ3lTaG9ydA==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.