473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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. }
Sep 3 '21 #1
1 7827
GazMathias
228 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
Sep 9 '21 #2

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

Similar topics

2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
6
by: Tim Cartwright | last post by:
I have a page that has the login control on it, nothing else. This page inherits from a master page, neither page has any code in it. This page works perfectly when running on the WebDev debug web...
0
by: Martin Henke | last post by:
Dear all, I've got a problem with my custom combo box. When I select an entry from it, then I get the error message: "An unhandled exception of type 'System.ArgumentOutOfRangeException'...
0
by: Qiang | last post by:
Anybody knows how to convert convert System.Windows.Forms.HtmlDocument to String? Any API or sample code will be greatly appreciated. thanks, Qiang
1
by: Christopher Houdeshell | last post by:
System.Web.UI.WebControls.Button can load a style based on XAML. This can be done by using the Style method. I was wondering if there was a way to apply a XAML Style to a...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
1
by: =?Utf-8?B?WmlnZ3lTaG9ydA==?= | last post by:
Using a Button control, I tried to reset its colour ("color" to those of you on the other side of the pond). I tried to use the BackColor attribute - but that is in System.Windows.Forms.Button....
5
by: Satish | last post by:
When i compile this function I get the error Cannot convert lambda expression of type System.delegate because it is not a delegate type. private void SetStatus(string status) { if...
17
by: Blau | last post by:
I'm trying to use the System.Windows.Controls namespace, but when I try to add a reference to it I don't see it in the list. I see a System.Windows.Forms, but not a System.Windows.Controls. Can...
1
by: vineetbindal | last post by:
I am using GridView in silver light application i am following some example blogg something scoutt's blog. i need to have access to my grid view in my cs file, when i type in "using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.