简体   繁体   中英

Edit Cell value of a datagridview after set datasource

I have a datagridview and set it's Datasource to a table from a dataset (data.xsd)

here is my question:

Is there any way to edit the value of the cells and then show them?

for example I have a currency field and for some reasons I have to store it as int in database but when I want to show it I need to change the format to currency again.

is there any way to do that?

In CellFormatting event of dataGridView you can do this:

private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if(e.ColumnIndex == 4)
            {
                e.Value = e.Value + "I Just changed";
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM