Solved

How to select (and display selection in cell) a value from a DataGridViewComboBoxColumn.

Posted on 2012-04-12
1
318 Views
Last Modified: 2012-06-22
I am a developer who is new to the DataGridView object.  I have a task to modify an existing DataGridView object (myDGView), so that one of the columns displays a certain value under specific circumstances.  There are two columns in myDGView: unit and association.  Unit is a DataGridViewTextBoxColumn and association is a  DataGridViewComboBoxColumn.  The values of association are binded to a database lookup table (Values are: "X", Y", Z").  When the user changes the value of unit (column 0), I need to check all of the rows in the myDGView to determine if any association (column 1) value = "X".  If not, I must display "X" as the default selected value for the association column of the current row.  Can anyone assist?
0
Comment
Question by:spazjr01
1 Comment
 
LVL 15

Accepted Solution

by:
Minh Võ Công earned 500 total points
ID: 37840881
private void DataGridView1_CellValueChanged(
    object sender, DataGridViewCellEventArgs e)
{
    if (e.ColumnIndex == 0)
      {
            DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "X";
      }
}
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now