Life in my own company

Its all up to me.
posts - 137, comments - 166, trackbacks - 113

My Links

News



Twitter



Tag Cloud

Archives

Post Categories

Play

Work

Infragistics and the WinGrid

Sometimes, working with the infragistics wingrid can be a PITA!  Take, for example, the act of making the current row active upon right click before the context menu is displayed.

You'd think they'd have a HitTest method or something similar, but they don't.  Well, they do, but that's on an UltraGridRow.AccessibleObject or something like that--totally useless for what I need to do.  First, I look in help.  Yup, nothing there.  So I jump out to devcenter.infragistics.com and it's my lucky day, they have an article (http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=8483) featuring how to make stuff happen when you right click on a wingrid.  Must be something they get asked quite frequently.

So, I follow the steps there and enter the following code:

Point mousePoint = new Point(e.X,e.Y);

UIElement element = ((UltraGrid)sender).DisplayLayout.UIElement.ElementFromPoint(mousePoint);

UltraGridCell cell = element.GetContext(typeof(UltraGridCell)) as UltraGridCell;

if (cell!= null)

{

cell.Row.Selected=true;

}

This ALMOST works, but not quite.  When you right click, the row you were on remains highlighted.  To make it work as expected, you have to reset the active row.  Here's the final code:

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

{

Point mousePoint = new Point(e.X,e.Y);

UIElement element = ((UltraGrid)sender).DisplayLayout.UIElement.ElementFromPoint(mousePoint);

UltraGridCell cell = element.GetContext(typeof(UltraGridCell)) as UltraGridCell;

if (cell!= null)

{

gridRecentSignups.ActiveRow=cell.Row;

cell.Row.Selected=true;

}

}

 

The Cell.Row.Selected may not be needed, but just in case, I left it in.  Oh what fun.

Print | posted on Tuesday, December 20, 2005 1:39 PM | Filed Under [ Work ]

Feedback

Gravatar

# re: Infragistics and the WinGrid

I agree that working with the Infragistics API can be a pain. However, there's a lot of power there that is nice to know is there. It only seems like I appreciate it when I have to do something special using the standard datagrid or other control for some reason. Talk about a pain.
12/20/2005 1:58 PM | Anthony Trudeau
Gravatar

# re: Infragistics and the WinGrid

I used multiselectionmode for selecting multiple cell but how do i get back the selected cell data in collection
8/13/2006 11:49 PM | Kapil Dalvi
Gravatar

# re: Infragistics and the WinGrid

Sometimes?? LOL..y thr r many painz, stupid ones too, but as pointed out, the alternatives are quite ugly :). Thanks for the info it has helped me gr8ly!
4/25/2008 2:32 PM | MarkC
Gravatar

# re: Infragistics and the WinGrid

Same goes with the rest of their components e.g. UltraExplorerBar

UIElement element = ultraExplorerBar1.UIElement.ElementFromPoint(e.Location);

UltraExplorerBarItem item =
element.GetContext(typeof(UltraExplorerBarItem)) as UltraExplorerBarItem;

if (item != null)
{
ultraExplorerBar1.ActiveGroup = item.Group;
ultraExplorerBar1.ActiveItem = item;
item.Checked = true;
}

I know the original comment was made a few years ago but its still a problem
5/2/2008 5:41 AM | aussiegaz

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 2 and 6 and type the answer here:

Powered by: