Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,

I have using a Multicombobox but i have one problem.

first I load two columns into my multicombobox from a data set

but when i go to another module of my aplication and when
i return to the multicombobox and clicked.

it display the data with erros.

I give you a picture that show you the error:



The code i have using is the following:

string sqlqwery = "select vehiculos.cod as codigo,nombre as Nombre from vehiculos,socio where vehiculos.cod_so=socio.cod order by vehiculos.cod asc;";
conexion con = new conexion();
DataSet myDs = new DataSet();
myDs = con.consulta(sqlqwery);
multiColumnComboBox1.DataSource = myDs.Tables[0];
multiColumnComboBox1.DisplayMember = "codigo";
multiColumnComboBox1.ValueMember = "codigo";
multiColumnComboBox1.Refresh();


Please give me any advice for this case.

Note:

the ListBox and ComboBox didn't have multi-column support, For that reasona using the Muliticombobox
you can see about that here: http://www.codeproject.com/KB/combobox/multicolumnlistbox.aspx (error)
the correct link is it: A data-bound multi-column combobox[^]
But I using this new control, but I found the mentioned problem behind.
Grettings I waiting for your helps

Thanks,
Posted
Updated 26-Jan-11 9:09am
v3
Comments
Nish Nishant 26-Jan-11 14:01pm    
There is no control in Winforms called MultiCombobox. So you must be using a 3rd party control. Can you give more details on what you are using? That may help folks in giving you a more suitable answer.
leocode7 26-Jan-11 14:35pm    
Hello,
the ListBox and ComboBox didn't have multi-column support, For that reason I'm using the Muliticombobox
you can see about that here: http://www.codeproject.com/KB/combobox/multicolumnlistbox.aspx
But I using this new control, but I found the mentioned problem behind.
Grettings I waiting for your helps
Nish Nishant 26-Jan-11 14:38pm    
The control you are using was written in June 2002 and used .NET 1.0. It may need to be modified/updated to work with newer versions of the framework. Are you open to using other similar controls? Or do you want to use this specific class?
leocode7 26-Jan-11 14:50pm    
Of course!! I open to use new controls in .NET 2.0 and others one...
Please give me the link for that access it! also i need the "MultiListbox" too
because i am using both controls (MultiCombobox and MultiListBox) and they are working bad in my aplication.
Thanks in advance.
Nish Nishant 26-Jan-11 14:52pm    
Ok, try this one then :

http://www.codeproject.com/KB/combobox/DotNetMultiColumnComboBox.aspx

I wrote it and it's a multi column combobox. It should work with the latest Winforms version (even though it originally targeted .NET 2.0).

I don't know of a listbox equivalent to my class.

I'll add this as an answer so anyone else visiting this thread knows what happened without going through all the comments.

The OP was using my multi-column combobox class as well as someone else's multi-column listbox class. He's started a separate thread for the listbox problem. But the fix to my class was to do this:

Replace:

C#
protected override void OnDataSourceChanged(EventArgs e)
{
  base.OnDataSourceChanged(e); 
  InitializeColumns(); 
}

with:

C#
protected override void OnDataSourceChanged(EventArgs e)
{
  InitializeColumns();
  base.OnDataSourceChanged(e); 
} 


I am not sure why that's needed now. I wrote the original code 4 years ago, and at the moment I don't have time to dig into why this might make a difference. But anyway that fixed the OP's problem with the combobox.
 
Share this answer
 
 
Share this answer
 
Comments
leocode7 27-Jan-11 12:16pm    
Hello friend but the problem of your link is that any element in two columns
is a different, but I want to have one element with two columns
For example:

CODE0052 |ALEX WOOL
CODE0015 |MARY ANDERSON

This two elements represents one registry per line (This is I want).
But in your link there are four elements (registries) in MultiListbox

Also I want to assign elements using DatSets.

Please give me one solution,

Thanks in advance,
leocode7 7-Feb-11 1:18am    
the solution is

1) Call begin update method
2) fill the multilistbox with datasource
3) call end update method

like this:

<pre lang="sql">this.multiColumnListBox1.BeginUpdate();
this.multiColumnListBox1.DataSource = myDs.Tables["dt"];
this.multiColumnListBox1.EndUpdate();</pre>
XML
the solution is
1) Call begin update method
2) fill the multilistbox with datasource
3) call end update method
like this:
<pre lang="sql">this.multiColumnListBox1.BeginUpdate();
                this.multiColumnListBox1.DataSource = myDs.Tables[&quot;dt&quot;];
                this.multiColumnListBox1.EndUpdate();</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900