467,923 Members | 1,392 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,923 developers. It's quick & easy.

windows form datagrid questions

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
Nov 17 '05 #1
  • viewed: 1262
Share:
2 Replies
http://www.syncfusion.com/FAQ/WinFor...44c.aspx#q689q

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Wayne" <Me******@community.nospam> wrote in message
news:Og**************@TK2MSFTNGP15.phx.gbl...
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


Nov 17 '05 #2
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_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = this.DataGrid1.HitTest(pt);

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

this.DataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column);
this.DataGrid1.Enabled = false;
this.DataGrid1.Select(hti.Row);
this.DataGrid1.Enabled = true;
}

}

private void DataGrid1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = this.DataGrid1.HitTest(pt);

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

this.DataGrid1.CurrentCell = new DataGridCell(hti.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

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by PAUL EDWARDS | last post: by
4 posts views Thread by Carl Fenley | last post: by
1 post views Thread by Rajesh Kumar Choudhary | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.