Click here to Skip to main content
15,912,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show full text in one text cell in a big textbox when I click the small button. of course, the small button only showed when the text cell has the focus or this row has the focus.

Please help me hwo to proceed. thanks in advance.
Posted
Comments
pankajupadhyay29 17-Mar-11 12:10pm    
provide your Markup here I think this can be done using javascript.

1 solution

C++
// This will show a button in the upper right corner
// of a cell in column 0 if a single cell in that
// column is selected or if a single row is selected
//
// button1 is defined elsewhere on the form
// and is initialized with the correct size and is not visible
//
// The click event handler for button1 can display a text box
// at the cell location or take any other appropriate action.

private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
    const int targetColumn = 0;

    DataGridViewCell cell = null;
    if ((dataGridView1.SelectedCells.Count == 1 &&
        dataGridView1.SelectedCells[0].ColumnIndex == targetColumn) ||
        dataGridView1.SelectedRows.Count == 1)
    {
        cell = dataGridView1.CurrentRow.Cells[targetColumn];
        Rectangle rect = dataGridView1.GetCellDisplayRectangle(cell.ColumnIndex,
            cell.RowIndex, true);
        button1.Parent = dataGridView1;
        button1.Location = new Point(rect.Right - button1.Width, rect.Top);
        button1.Visible = true;
    }
    else
        button1.Visible = false;
}
 
Share this answer
 
Comments
C# learning user 3-Jul-13 14:10pm    
Thanks for the help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900