-
satheeshpk said 11 months ago:
Hi,
I am using componentone grid . I am creating new row using inline add. if the user click outside of the grid then how can add the new row automatically into the grid. which means how can i refresh the grid with new row. how can i achieve this?
| # -
Hi,
You have not mentioned the type of DataSource for your grid i.e. whether it is a List
or DataTable.In case it is a DataTable, ItemSource should be set to 'DefaultView’ of the DataTable.
This way row is automatically added to the grid when a new Row is appended to the
DataTable.If you are using List, I would suggest you to replace it with ObservableCollection.
Using this you should be able to get the new rows to appear in the grid.Let me know if you have any doubts.
| # -
satheeshpk said 11 months ago:
Hi,
Thanks for your reply. I am using observaclecollection only. i can able to see with new row on inintal load. but my question is not that. my question is, user click new row and add some details in new row then the user click outside of grid. At that time new row have to be created with entered values in grid. how can i achieve this?
| # -
Hi,
In this case, you can call EndNewRow() method which takes boolean parameter to commit the
changes. However, the tricky part comes in when you need to detect whether the grid has lost
focus or not and when exactly you need to call 'EndNewRow’.Ideally LostFocus event should do the trick. But this event also fires when you put C1DataGrid
into edit mode as the focus shifts to internal editor. So you have to work around it.See the suggested code below.
Dim outFlag As Boolean = False Private Sub c1DataGrid1_LostFocus(sender As Object, e As System.Windows.RoutedEventArgs) Handles c1DataGrid1.LostFocus If outFlag = True Then c1DataGrid1.EndNewRow(True) End If End Sub Private Sub MainWindow_MouseLeftButtonDown(sender As Object, e As System.Windows.Input.MouseButtonEventArgs) Handles Me.MouseLeftButtonDown c1DataGrid1.EndNewRow(True) End Sub Private Sub c1DataGrid1_MouseEnter(sender As Object, e As System.Windows.Input.MouseEventArgs) Handles c1DataGrid1.MouseEnter outFlag = False End Sub Private Sub c1DataGrid1_MouseLeave(sender As Object, e As System.Windows.Input.MouseEventArgs) Handles c1DataGrid1.MouseLeave outFlag = True End SubI hope this will help. In case of any doubts, please do let me know.
Answer| #
You must be logged in to reply to this topic.

