Check the code of the cell value in win form DataGrid, from msdn.

Source: Internet
Author: User
Protected   Void Datagrid1_mousedown ( Object Sender, mouseeventargs E) {

// Use the hittest method to get a hittestinfo object.

System. Windows. Forms. DataGrid. hittestinfo Hi;

DataGrid Grid = (DataGrid) sender;

Hi = Grid. hittest (E. X, E. y );

// Test if the clicked area was a cell.

If (Hi. Type = DataGrid. hittesttype. Cell) {

// If it's a cell, get the gridtable and currencymanager of

// Clicked table.

Datagridtablestyle dgt = Datagrid1.tablestyles [ 0 ];

Currencymanager mycurrencymanager =  

(Currencymanager) This . Bindingcontext

[Mydataset. Tables [datagrid1.datamember];

// Get the rectangle of the clicked cell.

Rectangle cellrect;

Cellrect = Grid. getcellbounds (Hi. Row, hi. Column );

// Get the clicked maid.

Datagridtextboxcolumn gridcol =

(Datagridtextboxcolumn) dgt. gridcolumnstyles [Hi. Column];

// Insert code to edit the value.



}

}

Think of MS as an inexplicable thing. It is necessary to make such complicated things.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.