Solved

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

Posted on 2012-04-12
1
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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