We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DataGrid FAQ

private void Mousedownhere(object sender, System.Windows.Forms.MouseEventArgs e) { DataGrid myGrid = (DataGrid) sender; System.Windows.Forms.DataGrid.HitTestInfo hti; hti = myGrid.HitTest(e.X, e.Y); string message = "You clicked "; switch (hti.Type) { case System.Windows.Forms.DataGrid.HitTestType.None : message += "the background."; break; case System.Windows.Forms.DataGrid.HitTestType.Cell : message += "cell at row " + hti.Row + ", col " + hti.Column; message += "Row Number : "+Convert.ToString(myGrid.CurrentRowIndex)+"\r"+ myGrid[hti.Row, hti.Column]; fscount = hti.Row; break; case System.Windows.Forms.DataGrid.HitTestType.ColumnHeader : message += "the column header for column " + hti.Column; break; case System.Windows.Forms.DataGrid.HitTestType.RowHeader : message += "the row header for row " + hti.Row; fscount = hti.Row; string cellvalue = Convert.ToString(myGrid[hti.Row,2]); // if (cellvalue==”CHINA”) MessageBox.Show("value is="+cellvalue,Convert.ToString(hti.Row)); break; //BUT IF I REMOVE THE COMMENTS FROM THE ABOVE if (cellvalue==”CHINA ”) THEN IT DOES NOT SHOW ME //THE MESSAGEBOX // WHY??????????????? } } DataGridProblem_7034.zip

Loader.
Live Chat Icon For mobile
Up arrow icon