Solved

infragistics Ultragrid

Posted on 2016-07-25
6
97 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 34

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 34

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
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 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