Solved

infragistics Ultragrid

Posted on 2016-07-25
6
79 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 33

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 33

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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…

828 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