Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Please help me by commenting on this project!

 

This is a demonstration project intended to prove a concept. It is a combo box control that can be data bound to multiple fields of a data source, unlike the standard combo box that can be bound to a single field only. So instead of a list that reads:

 

Jimmy

Ronald

George

 

The list could read:

 

Carter, Jimmy

Reagan, Ronald

Bush, George

 

What I am most concerned about and what I most want feedback on is my approach for overriding the data binding of the base control.

 

The basic approach is that when binding to a data source, I pull the required information from the data source, format it as I want, and then store it into the base ComboBox�s ObjectCollection (Items property). So the MultiCombo control might be bound to a data source, but the inner base ComboBox is not � the ObjectCollection is exclusively manipulated by the MultiCombo.

 

Although I am handling the IBbindingList and CurrencyManager objects directly, I am worried that somehow there is still a way that the underlying ComboBox will take a new data source behind my back. This is not an issue in the data bound ListView control examples I�ve seen because the base control is not normally set up for data binding, and therefore, does not have the capability to move to a new data source. But a ComboBox does.

 

Please see the larger discussion on this in the comments of the MultiComb.cs class. Please also read the ReadMe text file to get the data base working right in the test application.

 

In addition to data binding, this also demonstrates using property descriptors and reflection, design-time property support and property editors.

 

Thanks.

multiitemcombo.zip

Posted

This would be useful and something that I'd need for a project I'm working on... but I can't get your project to work.

 

I got it running (shoulda made the connection with code and used Application.StartupPath + "\Database.mdb"), but when I do things, I get an error.

 

I have 3 labels, with two buttons below each label, a create and bind button. Then unbind below those three. A listbox to the right and a pause button on the bottom.

 

Is there supposed to be a MultiItemCombo on the screen somewere?

 

I see a MultiCombo.cs file. Is that the sourcecode for the control? Did you compile the control and add the .dll?

Posted
I did not include the dll in the zip file. Try compiling the project and checking object browser. Does MultiCombo show up in the MultiItemCombo namespace? Are the traditional looking MultiCombo hooks in the WindowsForms generated code section? Finally, yes, the MultiCombo.cs is the code to the control.
Posted
An unhandled exception of type 'System.NullReferenceException' occurred in MultiItemCombo.exe

 

Additional information: Object reference not set to an instance of an object.

 

Is the error I get when I try to "Bind DB"

 

pointed at the line of code in bold:

 

/// <summary> Bind to DataSet </summary>
	private void btnBDB_Click(object sender, System.EventArgs e)
	{
		this.dsNames1.Clear();
		this.oleDbDataAdapter1.Fill(this.dsNames1);

		[b]multiCombo1.SetDataBindings(dsNames1, "Contacts", "LastName, FirstName");[/b]
		
		listBox1.DataSource = dsNames1;
		listBox1.DisplayMember = "Contacts.FirstName";

	}

 

Yes, I can access the MultiCombo namespace through the code and through object browser.

 

Is there supposed to be a MultiCombo on the screen, or is it supposed to be created via code?

Posted

Perhaps this should be taken off line unless others are having the same problem.

 

What happens when the program is first run? It should come up with a MultiCombo that is already bound to the data set, although the list box is not. The list box won't bind until you press one of the Bind DB (or other) buttons. Do you even see the MultiCombo when the program is run?

 

The MultiCombo is created in the windows generated section:

this.multiCombo1 = new MultiItemCombo.MultiCombo();

// other code here

// 
// multiCombo1
// 
this.multiCombo1.DataMember = "Contacts";
this.multiCombo1.DataSource = this.dsNames1;
this.multiCombo1.DisplayMember = "LastName, State";
this.multiCombo1.DividerColor = System.Drawing.Color.Black;
this.multiCombo1.DividerWidth = 0F;
this.multiCombo1.Location = new System.Drawing.Point(8, 144);
this.multiCombo1.Name = "multiCombo1";
this.multiCombo1.Size = new System.Drawing.Size(232, 21);
this.multiCombo1.TabIndex = 1;
this.multiCombo1.Text = "multiCombo1";

If this is in your code, you should see the control at design time.

 

Any stepping though code you can do to find the null reference would be helpful. I presume that it is the dsNames1 data set. Please check to make sure the connection is properly established and the data set is being created.

 

If not, you might try to nuke my data tools and create a new set (Data Adapter, Connection, DataSet, etc.)

 

Please e-mail or PM me if I can be of further help.

Posted

After following up on some of the issues Denaes has asked about, I fixed a bug in the control (I'm sure more remain!) and have re-posted it below.

 

Also, when you first open the demonstration project, please build it, otherwise the MulitCombo control won't show up on the form. Please see the ReadMe and comments in MultiCombo.cs for more.

 

Thanks.

multiitemcombo.zip

Posted

In VB6, I used API calls to make a combobox's dropdown display a multi-column ListView control. That is what I did to get around this.

 

I like the control though.

Aspnot

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...