Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 26th, 2006, 08:02 AM
Registered User
 
Join Date: Apr 2006
Location: london, , United Kingdom.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagridview & combobox column

Please help me with my DataGridView...

I have got a DataGridView with a ComboBoxColumn.

I have set the DGV datasource to a table and I have populated the CBC by just adding items like this:
Me.colPosition.Items.Add(value), where value is an () of data.

Now, my questions are many, but firstly:

I really miss the properties & events that a regular combobox has, like selectedItem & selectedIndexChanged…
Or how do I deal with the usual stuff like setting the selectedIndex = 0 and getting the selectedItem like I normally do with a regular comboBox???

Is a conversion from a cell in the comboboxcolumn to a regular combobox necessary, or how do I do this?

I also get an Data error when I select something from my CBC and leave the CBC...

ANY suggestions are welcomed at this point!

Thanks you very much!





:O )
Reply With Quote
  #2 (permalink)  
Old July 31st, 2006, 02:31 AM
Registered User
 
Join Date: Jul 2006
Location: Mangalore, Karnataka, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sometimes it is helpful to know when a user has selected an item in the ComboBox editing control. With a ComboBox on your form you would normally handle the SelectedIndexChanged event. With the DataGridViewComboBox you can do the same thing by using the DataGridView.EditingControlShowing event. The following code example demonstrates how to do this. Note that the sample also demonstrates how to keep multiple SelectedIndexChanged events from firing.

private void dataGridView1_EditingControlShowing(object sender,
                    DataGridViewEditingControlShowingEventArgs e)
{
    ComboBox cb = e.Control as ComboBox;
    if (cb != null)
    {
        // first remove event handler to keep from attaching multiple:
        cb.SelectedIndexChanged -= new
        EventHandler(cb_SelectedIndexChanged);

        // now attach the event handler
        cb.SelectedIndexChanged += new
        EventHandler(cb_SelectedIndexChanged);
    }
}

void cb_SelectedIndexChanged(object sender, EventArgs e)
{
    MessageBox.Show("Selected index changed");
}

With Regards,
Ravi Madangallu
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
EditingControlShowing in DataGridView w 2 combobox mike_geomatics .NET Framework 2.0 1 September 21st, 2010 12:03 PM
ComboBox events in dataGridView mallikalapati Visual Studio 2005 0 February 27th, 2008 07:16 AM
DataGridView ComboBox StuckAgain C# 2005 1 February 22nd, 2008 09:59 AM
2 comboBox in the DataGridView mehrdad_T C# 0 January 20th, 2008 07:27 AM
Datagridview combobox issue aad1 C# 0 May 26th, 2006 01:00 PM



All times are GMT -4. The time now is 08:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.