all groups > dotnet compact framework > october 2005 >
You're in the

dotnet compact framework

group:

getting datagrid cell positions and size


getting datagrid cell positions and size jamie
10/28/2005 5:00:39 PM
dotnet compact framework:
I'm looking for a way to be able to edit data in the datagrid similar to how
it works in the full framework. My current thought is when I select a cell
in a datagrid place a textbox in the exact location and focus on the text
box, when done save the value in the datagrid and move the textbox.

Is there a way to get the location and size of the current sell on the
screen?

I'm thinking that on the currentcellchanged event find the currentcell
position on screen.
Set the textbox exactly to that size and position.
Then change the focus to the textbox.

Anyone see any issues with this?

Anyone have a better recommendation?

Jamie


Re: getting datagrid cell positions and size jamie
10/31/2005 10:30:09 AM
Noone has any advice?

I have read
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/datagridediting.aspx
as has been suggested. It works but doesn't give the look and feel that the
users want.


[quoted text, click to view]

Re: getting datagrid cell positions and size Sergey Bogdanov
10/31/2005 9:33:08 PM
Try this code:

Rectangle r = dataGrid1.GetCellBounds(dataGrid1.CurrentCell.RowNumber,
dataGrid1.CurrentCell.ColumnNumber);
r = dataGrid1.RectangleToScreen(r);

textBox.Top = r.Top - 26;
textBox.Left = r.Left;
textBox.Width = r.Width;
textBox.Height = r.Height;


Probably you will need VScroll/HScroll events of the grid:
http://groups.google.com/group/microsoft.public.dotnet.framework.compactframework/browse_frm/thread/c1c56299d08b30d3/50b62940f767437b#50b62940f767437b


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


[quoted text, click to view]
Re: getting datagrid cell positions and size Sergey Bogdanov
11/2/2005 12:00:00 AM
I was using this value to correct the top position of a cell. The value
26 is a height of a grid header. I'm sure it can be calculated using
private values of a DataGrid control but since a font is predifined you
can leave your "32" value as is.

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


[quoted text, click to view]
Re: getting datagrid cell positions and size jamie
11/2/2005 10:37:45 AM
This works thank you. Could you explain where the -26 comes from? I
found that I needed to set it to -32 on mine and I believe thats due to the
size of the box due to font size. What exactly is it doing?
[quoted text, click to view]
AddThis Social Bookmark Button