Hi Wayne
Interestingly, I've had to do exactly this today. If you start with the
Windows Forms FAQ (at Syncfusion), then that will get you started. I needed
row selection together with ReadOnly data, and also not having the text in
the cell highlighted when I clicked on it, and had to hack it together with a
MouseDown and MouseUp pair of handlers to set the Enable property on the
DataGrid to false, then to true while doing the selection - it felt like a
terrible hack (and I didn't test it much...), and would be interested to see
if other people have a more elegant way of achieving the same thing.
Nigel
private void DataGrid1_Mouse Down(object sender,
System.Windows. Forms.MouseEven tArgs e)
{
System.Drawing. Point pt = new Point(e.X, e.Y);
DataGrid.HitTes tInfo hti = this.DataGrid1. HitTest(pt);
if(hti.Type == DataGrid.HitTes tType.Cell)
{
this.DataGrid1. CurrentCell = new DataGridCell(ht i.Row, hti.Column);
this.DataGrid1. Enabled = false;
this.DataGrid1. Select(hti.Row) ;
this.DataGrid1. Enabled = true;
}
}
private void DataGrid1_Mouse Up(object sender,
System.Windows. Forms.MouseEven tArgs e)
{
System.Drawing. Point pt = new Point(e.X, e.Y);
DataGrid.HitTes tInfo hti = this.DataGrid1. HitTest(pt);
if(hti.Type == DataGrid.HitTes tType.Cell)
{
this.DataGrid1. CurrentCell = new DataGridCell(ht i.Row, hti.Column);
this.DataGrid1. Select(hti.Row) ;
}
}
Here's the code:
"Wayne" wrote:
I have a datagrid on my windows form, it needs to be read only and when a
user selects a row, I want the whole row to be selected.
How would I go about doing this?
--
Thanks
Wayne Sepega
Jacksonville, Fl
Enterprise Library Configuration Console Module Generator
http://workspaces.gotdotnet.com/elccmg
"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein