Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / February 2006

Tip: Looking for answers? Try searching our database.

DataGridViewComboBoxCell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kh - 24 Feb 2006 08:56 GMT
As previously noted I am implementing "AutoFilter" functionality in the
DataGridView, similar to that seen in Excel. This is done by inserting a row
of DataGridViewComboBoxCell objects at position zero in the grid and filling
each combo with a list of possible values for the Column in which it resides.

I have this working but I am not happy with my implementation. In order to
be able to detect a user change in filter conditions (which must be applied
to the displayed data immediately) I have attached a listener to
SelectedItemChanged of the ComboBox which is created within the
DataGridViewComboBoxCell when the cell enters edit mode, as follows:

private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
{
   // snip...

   // we must enter edit mode for the combo to be activated
   dataGridView1.BeginEdit(false);
   ComboBox comboBox = dataGridView1.EditingControl as ComboBox;
   if (comboBox == null)
       return;

   // attach listener
   comboBox.SelectedValueChanged += new
EventHandler(comboBox_SelectedValueChanged);
}

This is awkward and I have had to add a lot of other code to support it.
What I would prefer is to just capture changes to the underlying cell rather
than the ComboBox, but such changes are not available until the user moves
focus to another cell. Can anyone give me suggestions as to how I might do
this without having to listen to ComboBox events?

Many Thanks

kh
Luke Zhang [MSFT] - 27 Feb 2006 02:43 GMT
Hello,

I am not very clear about what you said about "just capture changes to the
underlying cell rather than the ComboBox". Why you need to capture changes
to the underlying cell since you want to capture user's selecttion the
combo box? Can you clarify more on this?

Thanks,

Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.