none
RowHeaderClick Event in DataGrid

    General discussion

  • Hi All,  

    DataGrid has a Protected Event RowHeaderClick.

    The following code is not good
     
    this.dataGrid1.RowHeaderClick += new EventHandler(DataGrid1_Click);

    error message is: 
    C:\VS\WindowsApplication1\Form3.cs(244): 'System.Windows.Forms.DataGrid.RowHeaderClick' is inaccessible due to its protection level

    How to handle this Protected Event?   

    Thanks a lot.
    Wednesday, January 19, 2005 4:35 PM

All replies

  • Hi,
    I believe the only way to get around this is to create your own DataGrid class that inherits from the DataGrid.  Then you can access the OnRowHeaderClick event.

    Hope this helps.

    Jeanie
    Thursday, January 20, 2005 5:09 PM
  • Hi.
    Jeanie said you, that yuo can use OnRowHeaderClickFunction...I think it is impossible, because it is protected function.
    I think, you can use this.dataGrid1.Click...
    after, in handler you will detect row header...For example:
        
       this.dataGrid1.Click+= new EventHandler(DataGrid1_Click)

       private void DataGrid1_Click(object sender, EventArgs e)
       {
               Point pt = this.dataGrid1.PointToClient(Cursor.Position);
               DataGrid.HitTestInfo hti = this.dataGrid1.HitTest(pt); 
               if(hti.Type == DataGrid.HitTestType.RowHeader)
                   {
                        //yes row header clicked. Some info will contained in hti...
                   }
       }
    Friday, January 21, 2005 2:17 AM
  • You can also inherit from DataGrid, and handle it event...How suggest you Jeanie
    Friday, January 21, 2005 2:24 AM
  • Thanks, All.
    Friday, January 21, 2005 3:13 PM