How to put datagridview column in edit mode

I have a bound datagridview.  I would like to have the user click a button that would put one entire column into edit mode.  Let the user go down the rows editing this column, then click a button to save the new data to the grid and then datasource.  I can get current cell in edit mode but not sure how to do a column.
mgmhicksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roshan DavisCommented:
the following link has multi-row editing. Some changes to this code would work for entire column
http://www.dotnetjohn.com/articles.aspx?articleid=83

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
williamcampbellCommented:
You could Fake the Column Selection by Hi-Lighting the rectangle. Then as Each Item is clicked or the User uses the arrow you can select the row for editing. To only edit the Cell in the column you will have to turn of 'editability' for the other cells. I think this is a property of the Cell.

The Code Snippet below does the 'fake' hilighting

In the DataGrid MouseDown Event you will  find out if you have selected a column header through the hit test. You then find the co-ordinate of the column and construct a rectangle out of that. If you are selecting multiple columns you can store the index of the columns and the rectangle in  ArrayList.

Make sure you clear the ArrayList when you HitType is None.
protected void dataGrid1_MouseDown (object sender, System.Windows.Forms.MouseEventArgs e)
{
m_HitTest = dataGrid1.HitTest(e.X,e.Y);
if ( m_HitTest.Type == DataGrid.HitTestType.ColumnHeader )
{
int xCoordinate = this.GetLeftmostColumnHeaderXCoordinate( m_HitTest.Column );
int yCoordinate = this.GetTopmostColumnHeaderYCoordinate( e.X, e.Y );
int columnWidth = dataGrid1.TableStyles[0].GridColumnStyles
m_HitTest.Column].Width;
int columnHeight = this.GetColumnHeight( yCoordinate );
columnRegion = new Rectangle( xCoordinate, yCoordinate, columnWidth, columnHeight );
m_RectangleOfSelectedColumns.Add(columnRegion);
m_IndexOfSelectedColumns.Add(m_HitTest.Column);
}
else if(m_HitTest.Type == DataGrid.HitTestType.None)
{
this.m_RectangleOfSelectedColumns.Clear();
m_IndexOfSelectedColumns.Clear();
this.dataGrid1.Refresh();
}
}

In the DataGrid paint method you just fill the rectangles you contructed before in MouseDown Event.

private void dataGrid1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
if (m_HitTest != null && m_HitTest.Type == DataGrid.HitTestType.ColumnHeader )
{
for (int i = 0; i < this.m_RectangleOfSelectedColumns.Count; i++)
{
Rectangle columnRegion = (Rectangle)m_RectangleOfSelectedColumns[i];
SolidBrush blackBrush = new SolidBrush( Color.FromArgb( 255, 0, 0, 0 ) );
SolidBrush darkGreyBrush = new SolidBrush( Color.FromArgb( 100, 229, 229, 229 ) );
Pen blackPen = new Pen( blackBrush, 1F );
g.FillRectangle( darkGreyBrush, columnRegion);
g.DrawRectangle( blackPen, columnRegion );
}
}
}

Open in new window

sureshchsahuCommented:
The following link has complete code for the "Q" that you asked for:

http://www.codeproject.com/KB/webforms/SetEntireDataGridColumnEd.aspx
mgmhicksAuthor Commented:
Thanks guys, all solutions were different ways to handle this, but all are pretty complicated, so I approached the problem just editing the traditional way.  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.