disabling and enabling datagrid row

Hi,

I have a datagrid with multiple columns, some of which has combox and datetime picker columns. I want all the rows of all columns be disabled. I want to enable only one row at a time only when user clicks first column of the datagrid. I am able to capture the row and column clicked by user but I cant figure out how to disable and enable a row of datagrid.

Following code shows how am I capturing the row and column clicked by user.

private void dGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)

{

if (sender is DataGrid )

{

DataGrid oDGrid = (DataGrid)sender;

System.Drawing.Point pt = new Point(e.X,e.Y);

DataGrid.HitTestInfo hti = oDGrid.HitTest(pt);

if(hti.Type == DataGrid.HitTestType.Cell )

{

if(hti.Column == 0)

{

oDGrid.Select(hti.Row);

}

}

}

}



Answer this question

disabling and enabling datagrid row

  • wd

    Not sure if this will work, but you can set the grid to be non-editable (or set each column that way) first thru properties, then...

    (Note that mytable is the tablename that the controls are based on/connected to.)

    System.Data.DataRowView SelectedRowView;

    myDataSet.myTableRow SelectedRow;

    SelectedRowView = (System.Data.DataRowView)myBindingSource.Current;

    SelectedRow = (myDataSet.myTableRow)SelectedRowView.Row;

    SelectedRowView.Row.BeginEdit

    Good luck

    G.


  • disabling and enabling datagrid row