Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

infragistics Ultragrid

Posted on 2016-07-25
6
Medium Priority
?
184 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 35

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 35

Accepted Solution

by:
sarabande earned 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Screencast - Getting to Know the Pipeline

610 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