?
Solved

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

Posted on 2012-04-12
1
Medium Priority
?
324 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 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