Solved

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

Posted on 2012-04-12
1
317 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
Comment Utility
private void DataGridView1_CellValueChanged(
    object sender, DataGridViewCellEventArgs e)
{
    if (e.ColumnIndex == 0)
      {
            DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "X";
      }
}
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

6 Experts available now in Live!

Get 1:1 Help Now