Retrieving contents of dataviewgrid

Posted on 2006-03-30
Last Modified: 2010-05-18
I have a C# 2005 application using a dataviewgrid object.  It is bound to a dataset generated through the datasource wizard of the control.  I would like to have access to the content of the cells in the grid. I have used the CellClick event and use the RowIndex and ColumnIndex Values but am having difficulty getting the cell content value.  Can anyone help me with this?
Thanks daforga
Question by:daforga
    LVL 6

    Accepted Solution


            private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
                string value = dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString();
                string formattedValue = dataGridView1[e.ColumnIndex, e.RowIndex].FormattedValue.ToString();
                MessageBox.Show("Value = " + value +Environment.NewLine+ "Formatted value = "+formattedValue);

    I'm not sure I understood your problem, does this answer it?

    Author Comment

    Thank you.  Just what I wanted.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    C# ConsolApp opens new window 16 43
    Add row in datatable 18 43 validation controls letting bad data through 2 21
    Aspnet xml 2 27
    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    754 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

    19 Experts available now in Live!

    Get 1:1 Help Now