Solved

infragistics Ultragrid

Posted on 2016-07-25
6
53 Views
Last Modified: 2016-07-27
Windows Forms app -

I want to set focus upon form activate to a infragistics Ultragrid.  I'm calling grid.focus() as the last line of code in form activate.    However, the grid does not have focus.   And I can't seem to determine where the focus is.     Hitting tab once will give the grid focus.  Is there anything odd about focus and the Ultragrid?  Do I also need to give focus to a row?
0
Comment
Question by:HLRosenberger
  • 4
  • 2
6 Comments
 
LVL 32

Expert Comment

by:sarabande
ID: 41729663
you may check the public property 'CanFocus' which seems to indicate whether the ultra grid can have the focus. it perhaps depends on whether the grid has editable cells.

if you want to select a row or cell rather than to setting the focus to the control, i found an answer at infragistic forum (http://www.infragistics.com/community/forums/t/31880.aspx):

The grid follows the current record of the data source to which it is bound by default, meaning you would just have to set the binding manager's Position property to the index of the record that you want to "select":

UltraGrid grid = this.ultraGrid;
BindingManagerBase bm = grid.BindingContext[grid.DataSource, grid.DataMember];
bm.Position = 0;

Note that you can also select and activate an UltraGridRow programmatically; set the UltraGrid.ActiveRow property to activate the row, and use the Rows property of the Selected object to select a row:

this.ultraGrid.ActiveRow = row;
this.ultraGrid.Selected.Rows.Add( row );

perhaps you have to set an active row in order to get the focus to the grid.

note the ultragrid also has property ActiveCell which could be set same as ActiveRow.

Sara
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41729914
The grid does not have any editable cells.  However, I can give it focus just by clicking anywhere within the grid.   That's all I want to do in code - give it focus.
0
 
LVL 32

Accepted Solution

by:
sarabande earned 500 total points
ID: 41730666
I'm calling grid.focus() as the last line of code in form activate.    However, the grid does not have focus.  
this can happen if some other control of your form gets the focus later. normally it is the first control in your form which has windows style bit WS_TABSTOP enabled. you may try to set the focus later. to see whether setting focus works at all you may add a button to your form and call grid.focus(); when the button was clicked.

did you check whether grid.canfocus is true or false?

Sara
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:HLRosenberger
ID: 41731786
ah, grid.canfocus is false, right after I call  grid.Focus() in form.activated.   So, where should I call grid.Focus() ?  Isn't form.activated the last form event?
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41731796
Ah, I moved grid.Focus to AfterLoad event.  that did the trick!  

Thanks!
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41731797
Thanks!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now