ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.FirstCellInGrid).
ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.entereditmode).
When are you doing this? In what event?
in the Constructor method of the class. basically, i am starting out with an empty grid and want the user to populate it using the 'AddRowOnTop'. i want focus to be in the first field so they can just start typing without having to mouse click. i have been trying to figure out how to programmatically set ActiveRow = the AddRow with no luck. thanks for getting back to me on this.
If you click on the TemplateAddRow, then the focus is going to go into the cell that was clicked? You want to force the user into the first cell, even when they explicitly click on a different cell?
My guess is that you are unable to do this because of timing. You are probably setting the ActiveCell before the mouse message has been completely processed, which means your code is working, but then the focus gets taken away again. So you might have to find a better event to do what you want, or perhaps use a BeginInvoke to create a delay before your code is executed.
Thanks for your replay. Maybe I'm trying the wrong solution here. I just want to make sure that the key value is provided first when adding a new row, so that I can check if the entered key value maybe already of an existing row (which means you are updating an existing row instead of creating a new one).
I'm looking for a best practice for maintaining data in an ultragrid. Would there be a simple example somewhere for just creating, updating and deleteing data with an ultragrid (preferably with a TemplateAddRow)?
alexbink said:Thanks for your replay. Maybe I'm trying the wrong solution here. I just want to make sure that the key value is provided first when adding a new row, so that I can check if the entered key value maybe already of an existing row (which means you are updating an existing row instead of creating a new one).
I would probably use the BeforeRowUpdate event for this and any other row-level validation that you need to do. BeforeRowUpdate will fire for both existing and new rows, but you can simply check the IsAddRow property on the row to determine which type of row you are dealing with.
Hello all,
I have a very similar problem but even using the suggestions above I cant get it to work.
Heres my code under a button. Grid is already displayed on the form and form is loaded.
Try With uwGrid_CN_St1_QuoteItems .DisplayLayout.Bands(0).AddNew() .Selected.Rows.Clear() .Rows(.Rows.Count - 1).Selected = True .ActiveRow = .Selected.Rows(0) uwGrid_CN_St1_QuoteItems = objTools.uwgInitRowSelectedPointer(uwGrid_CN_St1_QuoteItems, strWhoAmI) With .DisplayLayout.ActiveRow .Cells("ID").Value = "0" .Cells("InvID").Value = "0" .Cells("Item Description").Value = "Items description to go Here!" .Cells("Karat").Value = "0" .Cells("Weight(DWT)").Value = "0" .Cells("Buying Price").Value = "0" End With End With vBtn_CN_St1_RemoveItem.Enabled = True vBtn_CN_St1_CreateQuote.Enabled = True Catch ex As Exception objTools.RecordErrorMsg(ex.Message, My.Application.Info.Title, My.Application.Info.Version.ToString, strWhoAmI, strWhoCalledMe, "", "", msUserID, msStoreIdToUse) End Try
I would like focus to be on the .Cells("Item Description"). cell with "Items description to go Here!"selected.
I have tried .Cells("Item Description").SelectAll() deirectly after the line: .Cells("Item Description").Value = "Items description to go Here!"
But no good. Also tried in the After Row insert event but that didn't help either.
Any ideas would be welcome. This seems like it should be a easy thing to do.
Thanks
Deasun
Hi Deasun,
You are mixing up selected and active. You can get rid of these two lines of code:
.Selected.Rows.Clear().Rows(.Rows.Count - 1).Selected = True
They will do nothing. Selection will get cleared once you add a new row, anyway, and you can't have selected rows while a cell is in edit mode.
You also don't need to set the ActiveRow. The AddNew call will do that for you automatically. So you can get rid of this line:
.ActiveRow = .Selected.Rows(0)
Now... to answer your question, what you need to do is set the ActiveCell to the appropriate cell and then use the PerformAction method to EnterEditMode:
.ActiveRow = .Cells("Item Description") .PerformAction(EnterEditMode, False, False)
.ActiveRow = .Cells("Item Description")
.PerformAction(EnterEditMode, False, False)
Hi Mike ,
There is an issue , when I am tabbing it is giving me a "Object reference not set to an instance of an object exception" ..
below is the exception details , when I debugged I got to know that "obj.FocusControl " is null ,pls guide me in this on setting the Focus Control property with some thing from the code.
Exception Message:
Object reference not set to an instance of an object.
---------------------------------------------------------------------------------------------------
Stack Trace:
at views..SearchGrid_KeyDown(Object sender, KeyEventArgs e)
at System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)
at Infragistics.Win.UltraControlBase.OnKeyDown(KeyEventArgs e)
at Infragistics.Win.UltraWinGrid.UltraGridBase.EditorContainerControlOnKeyDown(KeyEventArgs e)
at Infragistics.Win.UltraWinGrid.UltraGridBase.OnKeyDownForwarded(KeyEventArgs e)
at Infragistics.Win.UltraWinGrid.UltraGridLayout.OnEditorKeyDown(Object sender, KeyEventArgs e)
at Infragistics.Win.EmbeddableEditorBase.RaiseKeyDownEvent(KeyEventArgs e)
at Infragistics.Win.EmbeddableTextBox.OnKeyDown(KeyEventArgs e)
at Infragistics.Win.EmbeddableTextBoxWithUIPermissions.ProcessKeyMessage(Message& msg)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.WndProc(Message& m)
at Infragistics.Win.EmbeddableTextBoxWithUIPermissions.WndProcInternal(Message& m)
at Infragistics.Win.EmbeddableTextBoxWithUIPermissions.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
For staying the new row of the UltraWinGrid 2010, these lines work for me in the BeforeRowUpdate event:
e.Cancel = True grdTranslationFields.RowUpdateCancelAction = RowUpdateCancelAction.RetainDataAndActivation e.Row.Cells(5).Activate()
Hope that help.
I am not able to put focus in newly added row. I am doing through javascript : My code is
var grid = igtbl_getGridById('<%=uwgSiteAlias.ClientID%>'); var rows = grid.Rows;
var nRow = rows.addNew();var LastRow = rows.getRow(rows.length-1);
var cmd = "<a href='BLOCKED SCRIPTremoveRow()'>remove</a>";
LastRow.getCell(4).setValue(cmd); LastRow.getCell(4).getElement().innerHTML = cmd LastRow.activate(true);
Regards,
Pawan Shah
Hi Seema,
I'm having trouble understanding what you mean, but it sounds like maybe you are trying to perform an operation on the selected text inside a cell without losing focus. If you use a button control, then the button will take focus away from the grid and you will lose the selection - so that won't work. Typically, formatting buttons like are would be toolbar buttons which do not take focus. It's the same with Cut, Copy, and Paste - you have to use a control that doesn't take the focus away. Otherwise you lose the context of what you are cutting, copying, or pasting.
hi,
I am also facing the same issue, where i am selecting few characters from the activecell text and then want to color only those characters.
but the grid looses its editmode property and if i explicitely add it by using
PerformAction(UltraGridAction.EnterEditMode);
it looses the selection event thought the cell regains its editmode property.
Can i get the selection of characters after using
PerformAction(UltraGridAction.EnterEditMode); funtion.
Please let me know, or can you provide some alternative for the same.
Thanks & Regards,
Seema Sharma