Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7981515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:23:52+00:00 2026-06-04T10:23:52+00:00

I want to display a particular cell value a row in a ShowRichMessageBox when

  • 0

I want to display a particular cell value a row in a ShowRichMessageBox when i click on the button but this event display the cell value if click anywhere on the row….!

what is wrong here…..How can I fix the above problem???

I have some logvalues which are big but it’s already loaded in the cell so,
Is it possible to expand the row when i select a particular row in the datagridview???

 public LogView()
    {
        InitializeComponent();
        this.dataGridView2.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_buttonCol);

        bindingList = new SortedBindingList<ILogItemView>();
        dataGridView2.DataSource = bindingList;
        this.dataGridView2.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
        this.dataGridView2.MultiSelect = false;
        var buttonCol = new DataGridViewButtonColumn(); // The button to display a particular cell value when clicks//
        buttonCol.Name = "ButtonColumnName";
        buttonCol.HeaderText = "Show";
        buttonCol.Text = "View";
        buttonCol.UseColumnTextForButtonValue = true;    
        dataGridView2.Columns.Add(buttonCol);

    }

    private void dataGridView2_buttonCol(object sender, DataGridViewCellEventArgs e)
    {

            string name = Convert.ToString(dataGridView2.SelectedRows[0].Cells[2].Value);
            ShowRichMessageBox("Code", name);

    }

Edit:

if (e.ColumnIndex != 0) // Change to the index of your button column
            {
                return;
            }

            if (e.RowIndex > -1)
            {
                string name = Convert.ToString(dataGridView2.Rows[e.RowIndex].Cells[2].Value);
                ShowRichMessageBox("Code", name);
            }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:23:55+00:00Added an answer on June 4, 2026 at 10:23 am

    The DataGridViewCellEventArgs instance passed to the CellClick event handler has a ColumnIndex property, which you can check to see if the click came from the button column.

    Like this:

    private void dgv_buttonCol(object sender, DataGridViewCellEventArgs e)
    {
            if (e.ColumnIndex != 4) // Change to the index of your button column
            {
                 return;
            }
    
            if (e.RowIndex > -1)
            {
                string name = Convert.ToString(dgv.Rows[e.RowIndex].Cells[2].Value);
                ShowRichMessageBox("Code", name);
            }
    }
    

    For the second part of your question, I’m not sure what you mean but you could certainly change the row height, perhaps using in the SelectionChanged event, or if you want to do something more in depth see “How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please anybody help me. i want to display the particular attribute and its value
i binded some items to listbox.whenever click on particular listitem i want to display
I am doing a project in which i want to display a particular message
I want to display only children categories of a particular category. Suppose I have
I want to display the total number of comments for a particular post in
Ultimately, I want to add an <iframe> to the display of a particular model
I want display data from database in Listbox...Here is my code, It is not
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
In the header of the django admin, I want display a link. This link
I want to display a facebox link when I click on a element when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.