473,321 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

windows forms datagrid view combo box is loosing its selection on selecting other row

Need urgent help here I have a data grid showing company name and filters in drop down
/* filters in drop down are according to company name in that row *\
Expand|Select|Wrap|Line Numbers
  1. //for binding list to combo box on its click 
  2. private void dgvJournalEntries_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { //selection of combo box List LstCompanyFiltersGrdOpr = this.bsEnterpriseCompanyFIlter.DataSource as List;
  3.  
  4.         if (dgvJournalEntries.Columns[dgvJournalEntries.CurrentCell.ColumnIndex].Name == "CompanyFilters")
  5.         {
  6.             ComboBox combo = e.Control as ComboBox;
  7.             if (combo != null)
  8.             {
  9.                 // Remove an existing event-handler, if present, to avoid  
  10.                 // adding multiple handlers when the editing control is reused.
  11.  
  12.                 combo.DropDown -= new EventHandler(combo_DropDown);
  13.                 // Add the event handler. 
  14.  
  15.                 combo.DropDown += new EventHandler(combo_DropDown);
  16.  
  17.  
  18.  
  19.             }
  20.         }
  21.  
  22.  
  23.     }
  24. //And for Binding List // void combo_DropDown(object sender, EventArgs e) { List LstCompanyFiltersGrdOpr = this.bsEnterpriseCompanyFIlter.DataSource as List;
  25.  
  26.         ComboBox combo = sender as ComboBox;
  27.         combo.BeginUpdate();
  28.         int currentColIndex = dgvJournalEntries.CurrentCell.ColumnIndex;
  29.         int currentRowIndex = dgvJournalEntries.CurrentCell.RowIndex;
  30.         string preColumnCompanyValue = dgvJournalEntries[currentColIndex - 1, currentRowIndex].Value.ToString();
  31.         var CompanyFilterList = LstCompanyFiltersGrdOpr.Where(X => X.CompanyName == preColumnCompanyValue).SelectMany(X => X.tEDJFilterList).ToList();
  32.         if (CompanyFilterList.Count() > 0)
  33.         {
  34.             combo.DataSource = CompanyFilterList.Select(C => C.FName).ToList();
  35.  
  36.         }
  37.         combo.EndUpdate();
  38.  
  39.     }
  40.  
  41.  
// But the issue is after selecting a value in from drop down when i click on any other cell or row , previous drop down lost its selected value
Jun 20 '13 #1
0 1010

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Chris Mayers | last post by:
I have a Windows Forms DataGrid that has a DataView as a datasource. My problem is that I want the datagrid to exhibit some special sorting properties when the header rows are clicked on. From...
3
by: Steven.Xu | last post by:
Hello everyone. Normally, the cell of the System.Windows.Forms.DataGrid could be inputed. How can I let the cells only show something and not be inputed?
3
by: max | last post by:
I can generate this error by NOT assigning a tableName to the view: at System.Windows.Forms.DataGrid.AddNewRow() at System.Windows.Forms.DataGridAddNewRow.OnEdit() Is there any possibility of...
1
by: Dominik Luyten | last post by:
Hi, I would like to format certain DataRows in a Windows.Forms.DataGrid. I know how to do that for the columns, but I cannot find a way to assign a specific font, color etc. to a specific kind...
3
by: scott | last post by:
hi all, hope some one can help iv created a datagrid that points to a DataView. the data view takes in a DataTable. The DataTable then adds the columns using DataColumn. All fine so far. ...
3
by: philip.mckee | last post by:
Hi all I am looking to return the width of a given column in a Windows.Forms.DataGrid at runtime. This would seem to be a much needed straight forward property request, but I can't find a simple...
11
by: Michael Kellogg | last post by:
I have a collection of custom objects that I am displaying in a Windows Forms Datagrid. To display it, I take the collection and build a DataTable object on the fly, then set the grid's DataSource...
0
by: Reddy4All | last post by:
Hi- Is there any possiblity to make Datagrid control (Winforms) column header sort arrow more prominent in .net 2003. In Windows forms Datagrid control, when user click on the column header, default...
0
by: Reddy4All | last post by:
Hi- Is there any possiblity to make Datagrid control (Winforms) column header sort arrow more prominent in .net 2003. In Windows forms Datagrid control, when user click on the column header, default...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.