This is a migrated thread and some comments may be shown as answers.

How to know absolute cell position in grid

3 Answers 557 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Daniel Sprague
Top achievements
Rank 1
Daniel Sprague asked on 26 Feb 2010, 05:35 PM
Hi Everyone,

I have a grid on a winform.  The grid has a "notes" column in it.  When the user goes to edit the notes, I have a little popup - text editing window appear - something similar to the text property drop down editor in the property sheet of visual studio.

What I can't figure out is how to correctly position the little popup text editing window.  It should be displayed immediately below the grid's current cell and left aligned with the cell.

The problem I'm having is how to determine the absolute position of the grid's current cell, taking into account other grid elements (header rows, group header rows, new record rows), and also taking into account the Y position, especially when the grid may be scrolled to the left.

I've put the code to display the popup in the CellEditorInitialized event of the grid, which works great for knowing which cell is being edited, with the event args.  But only if that event also had mouse args. 

Anyone have any ideas?

Thanks much!
Dan

3 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 01 Mar 2010, 08:37 AM
Hi Daniel Sprague,

When you enter edit mode, the grid changes its current cell. You can determine the current cell using the property CurrentCell of the grid. You are on the right way. You can use CellEditorInitialized event to change the location of your window. You need only to convert the location of the cell using the absolute position. You can use PointToScreen method of the cell to convert its location in screen coordinates. You can use the following code snippet:

private void radGridView_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    Point absolutePosition =  this.radGridView.CurrentCell.PointToScreen(this.radGridView.CurrentCell.Location);
}

If you need further assistance feel free to contact us back.

Sincerely yours,
Svett
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Avi
Top achievements
Rank 1
answered on 20 Dec 2010, 12:27 PM
Hello,

I am using telerik:RadGridView.

Outside the grid, at the bottom, I want to position a stackpanel exactly under it's 6th column.
Using margins does not help because it changes between screen resolutions.

How do I find the relative position for the stackpanel?

The code is like this :

<telerik:RadGridView>
........
</telerik:RadGridView>

<StackPanel
            Margin="0,10,170,0"
            HorizontalAlignment="Center"
            Orientation="Horizontal">
            <TextBlock VerticalAlignment="Center" Text="Total Balance:" />
            <Border VerticalAlignment="Top">
                        <TextBlock Width="100"
                                VerticalAlignment="Center"
                                FlowDirection="LeftToRight"
                                Padding="3"
                                Text="{Binding TotalPaymentBalance,  StringFormat='{}{0:C2}',Mode=OneWay}" />
                        </Border>
</StackPanel>

Thanks
0
Vlad
Telerik team
answered on 20 Dec 2010, 12:36 PM
Hi,

 Please post your questions in the relevant forum category!

All the best,
Vlad
the Telerik team
Check out the Q1 2011 Roadmap for Telerik Controls for Windows Forms.
Tags
GridView
Asked by
Daniel Sprague
Top achievements
Rank 1
Answers by
Svett
Telerik team
Avi
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or