Results 1 to 3 of 3

Thread: [RESOLVED] [2.0] DataGridViewComboBoxColumn "Events"

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Location
    Madrid
    Posts
    325

    Resolved [RESOLVED] [2.0] DataGridViewComboBoxColumn "Events"

    Hi,
    Would sb know how to capture a "Selected Item Change", from DataGridViewComboBoxColumn. (This would be a DataGrid Column, with a combo box format. (winforms)).

    Thanks.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] DataGridViewComboBoxColumn "Events"

    Quote Originally Posted by Rauland
    This would be a DataGrid Column, with a combo box format.
    It would actually be a DataGridView column. A DataGrid is not the same thing as a DataGridView.

    The column has no event for a selection change because the column may contain hundreds or even thousands of cells. Each of those cells will contain a ComboBox control if and when it is being edited. Different cells may use the same or different ComboBox controls at different times. This is how the DataGridView works. It creates a control of the appropriate type when a cell needs to be edited. It also reuses the same control in different cells to increase efficiency.

    So, what do you do? You handle the EditingControlShowing event, at which point you know a control has been created for editing a cell. You can check whether the e.Control property refers to a ComboBox control and, if it does, attach a handler to its SelectionChangeCommitted or SelectedIndexChanged event. Just note that making a selection in a combo box cell does not change the value in that cell until the editing session is ended, which basically means when the user moves to another cell.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Location
    Madrid
    Posts
    325

    Re: [2.0] DataGridViewComboBoxColumn "Events"

    Thanks Jmcilhinney, wouldn´t of solved my prob without your help.

    I also found this link, other people might find it useful to.

    http://forums.microsoft.com/msdn/sho...12780&siteid=1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width