473,668 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ToolStripComboB ox DataBind

bds
Is there any way to databind a ToolStripComboB ox?

I have a form where I'd like a databound combobox to be the parameter
selection of a DataGridView. This combobox comes from a table with your
basic two column id and description fields. I'm interested in displaying the
descriptions in the combobox and having the id be used for the parameter.

I can see how this can be done with a simple combobox, but I do not see
DataBinding for the ToolStripComboB ox.

I can also imagine just manually filling the ToolStringCombo Box after
InitializeCompo nent, but I'm not quite sure the best way to store id/value
and then use the id for the parameter of the grid.

Maybe I could also create a custom control for the ToolStrip?

-bds
Aug 27 '05 #1
3 7566
bds
I was able to do what was needed with the following.

1. Manually fill strings into the ToolStringCombo Box inside the Form using
a DataSet. I do this in the Form constructor.

2. At the same time I fill the strings, I add the IDs to a new private
ArrayList member of the Form.

3. My TableAdapter.Fi ll takes the ID parameter as its second parameter. I
use the ToolStringCombo Box.SelectedInd ex and do a lookup of the ID in my Form
private ArrayList. MyTableAdapter. Fill gets called in the Form
fillToolStripBu tton_Click event handler.

That's about it. This is fine for what I needed, however I'm still
interested to find out if anybody has a more elegant solution with
DataBinding - even if the post is just theory and hasn't been tried yet.

-bds
"bds" wrote:
Is there any way to databind a ToolStripComboB ox?

I have a form where I'd like a databound combobox to be the parameter
selection of a DataGridView. This combobox comes from a table with your
basic two column id and description fields. I'm interested in displaying the
descriptions in the combobox and having the id be used for the parameter.

I can see how this can be done with a simple combobox, but I do not see
DataBinding for the ToolStripComboB ox.

I can also imagine just manually filling the ToolStringCombo Box after
InitializeCompo nent, but I'm not quite sure the best way to store id/value
and then use the id for the parameter of the grid.

Maybe I could also create a custom control for the ToolStrip?

-bds

Aug 29 '05 #2
Hi,

"bds" <bd*@discussion s.microsoft.com > wrote in message
news:E1******** *************** ***********@mic rosoft.com...
I was able to do what was needed with the following.

1. Manually fill strings into the ToolStringCombo Box inside the Form
using
a DataSet. I do this in the Form constructor.

2. At the same time I fill the strings, I add the IDs to a new private
ArrayList member of the Form.

3. My TableAdapter.Fi ll takes the ID parameter as its second parameter.
I
use the ToolStringCombo Box.SelectedInd ex and do a lookup of the ID in my
Form
private ArrayList. MyTableAdapter. Fill gets called in the Form
fillToolStripBu tton_Click event handler.

That's about it. This is fine for what I needed, however I'm still
interested to find out if anybody has a more elegant solution with
DataBinding - even if the post is just theory and hasn't been tried yet.
The ToolStripComboB ox host a ToolStripComboB oxControl that inherits from the
normal ComboBox, so you can cast the hosted control (see Control property)
to a ComboBox, once you have that it's normal DataBinding.
Eg.:

Form_Load( .... )
{
ComboBox cb = (ComboBox)toolS tripComboBox1.C ontrol;
cb.DataSource = someDataTable;
cb.DisplayMembe r = "columname-for-text";
cb.ValueMember = "colunmname-for-values";
}

// add a normal event for SelectedIndexCh anged on the ToolStripComboB ox
private void toolStripComboB ox1_SelectedInd exChanged(objec t sender,
EventArgs e)
{
// SelectedValue should give you the ID you want
Console.WriteLi ne(((ComboBox)t oolStripComboBo x1.Control).Sel ectedValue);
}
HTH
Greetings


-bds
"bds" wrote:
Is there any way to databind a ToolStripComboB ox?

I have a form where I'd like a databound combobox to be the parameter
selection of a DataGridView. This combobox comes from a table with your
basic two column id and description fields. I'm interested in displaying
the
descriptions in the combobox and having the id be used for the parameter.

I can see how this can be done with a simple combobox, but I do not see
DataBinding for the ToolStripComboB ox.

I can also imagine just manually filling the ToolStringCombo Box after
InitializeCompo nent, but I'm not quite sure the best way to store
id/value
and then use the id for the parameter of the grid.

Maybe I could also create a custom control for the ToolStrip?

-bds

Aug 29 '05 #3
bds
Thanks for the response. I guess it would help if I looked at the object
model a bit closer. I'll give this a try when I have a moment because I do
think it is cleaner.

-bds
"Bart Mermuys" wrote:
Hi,

"bds" <bd*@discussion s.microsoft.com > wrote in message
news:E1******** *************** ***********@mic rosoft.com...
I was able to do what was needed with the following.

1. Manually fill strings into the ToolStringCombo Box inside the Form
using
a DataSet. I do this in the Form constructor.

2. At the same time I fill the strings, I add the IDs to a new private
ArrayList member of the Form.

3. My TableAdapter.Fi ll takes the ID parameter as its second parameter.
I
use the ToolStringCombo Box.SelectedInd ex and do a lookup of the ID in my
Form
private ArrayList. MyTableAdapter. Fill gets called in the Form
fillToolStripBu tton_Click event handler.

That's about it. This is fine for what I needed, however I'm still
interested to find out if anybody has a more elegant solution with
DataBinding - even if the post is just theory and hasn't been tried yet.


The ToolStripComboB ox host a ToolStripComboB oxControl that inherits from the
normal ComboBox, so you can cast the hosted control (see Control property)
to a ComboBox, once you have that it's normal DataBinding.
Eg.:

Form_Load( .... )
{
ComboBox cb = (ComboBox)toolS tripComboBox1.C ontrol;
cb.DataSource = someDataTable;
cb.DisplayMembe r = "columname-for-text";
cb.ValueMember = "colunmname-for-values";
}

// add a normal event for SelectedIndexCh anged on the ToolStripComboB ox
private void toolStripComboB ox1_SelectedInd exChanged(objec t sender,
EventArgs e)
{
// SelectedValue should give you the ID you want
Console.WriteLi ne(((ComboBox)t oolStripComboBo x1.Control).Sel ectedValue);
}
HTH
Greetings


-bds
"bds" wrote:
Is there any way to databind a ToolStripComboB ox?

I have a form where I'd like a databound combobox to be the parameter
selection of a DataGridView. This combobox comes from a table with your
basic two column id and description fields. I'm interested in displaying
the
descriptions in the combobox and having the id be used for the parameter.

I can see how this can be done with a simple combobox, but I do not see
DataBinding for the ToolStripComboB ox.

I can also imagine just manually filling the ToolStringCombo Box after
InitializeCompo nent, but I'm not quite sure the best way to store
id/value
and then use the id for the parameter of the grid.

Maybe I could also create a custom control for the ToolStrip?

-bds


Aug 29 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1416
by: autofill | last post by:
2 scenario inside a WebUserControl. I want to know why Microsoft and so many book doesn't suggest us to work like that. This control going to be in my page and I will call the DataBind of my user control. PAGE page_load(....) { if(!IsPostBack) { this.WebUserControl1.DataBind();
0
1595
by: Job Lot | last post by:
How can i bind ToolStripComboBox to a DataTable? There is no DataSource, DisplayMember & ValueMemeber property? Thanks
3
12015
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the DataTable, then I discovered the asp:Table has a DataBind method. But the method takes no args and so I'm confused how to use it. Is there a link to see how DataBind works for asp:Table? Should I just use my own code anyway? Thanks... Here's my...
2
1767
by: Jim Bancroft | last post by:
Hi everyone, I have a DropDownList I populate as outlined below. This is from my code-behind file: private void Page_Load(object sender, System.EventArgs e) { BindMyData(); DataBind(); }
5
11477
by: Manuel | last post by:
How can I add an item to a ToolStripComboBox and specify a DisplayMember and a ValueMember?
3
1036
by: bds | last post by:
Is there any way to databind a ToolStripComboBox? I have a form where I'd like a databound combobox to be the parameter selection of a DataGridView. This combobox comes from a table with your basic two column id and description fields. I'm interested in displaying the descriptions in the combobox and having the id be used for the parameter. I can see how this can be done with a simple combobox, but I do not see DataBinding for the...
1
2164
by: Jim Hubbard | last post by:
Why isn't the Keypress event of the System.Windows.Form.ToolStripComboBox triggered by hitting the Enter key? I cannot trap Keys.Enter or Keys.Return in the Keypress event.
2
4891
by: Jason Richmeier | last post by:
Perhaps it is because it is the end of the day and my eyes are tired of looking at code but I cannot seem to figure out what I am doing wrong and what I can do (if anything) to fix it. On a Windows form, I have a ToolStripComboBox object with a handful of entries in the Items collection. I would like to change the text of the ToolStripComboBox object (using the Text property) to something other than the text of one of the items in the...
0
1232
by: McPolu | last post by:
Hello. I am trying to set ToolStripComboBox.DroppedDown inside of the Leave event and it does not work: public class MyToolStripComboBox : ToolStripComboBox { public MyToolStripComboBox() { Leave += new EventHandler(ExtendedToolStripComboBox_Leave);
0
8462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8583
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7401
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4205
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2791
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.