We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Please help with selection.....

Thread ID:

Created:

Updated:

Platform:

Replies:

39775 Jan 18,2006 04:08 AM Feb 17,2006 06:48 AM Windows Forms 13
loading
Tags: GridControl
I Gusti Ngurah Wirawan
Asked On January 18, 2006 04:08 AM

Hi, I use GridDataBoundGrid to display my data. i just want to capture when selection is changed and allow it or cancel the selection. which of then events i should choose. because when i attach the SelectionDragging event it won''t be fired by the grid. Many thanks before. Wirawan

stanleyj [Syncfusion]
Replied On January 18, 2006 04:30 AM

Hi Wirawan, Please try in gridDataBoundGrid1.Model.SelectionChanging / gridDataBoundGrid1.Model.SelectionChanged handler. Best regards, Stanley

I Gusti Ngurah Wirawan
Replied On January 18, 2006 04:35 AM

Thanks Stanley for your quick response. Btw why the event is trigered twice by the grid. First is the empty range and the second is the actual range. Regards, Wirawan. >Hi Wirawan, > >Please try in gridDataBoundGrid1.Model.SelectionChanging / gridDataBoundGrid1.Model.SelectionChanged handler. > >Best regards, >Stanley

stanleyj [Syncfusion]
Replied On January 18, 2006 04:53 AM

Hi Wirawan, SelectionChanged is raised when a cell/range is added to the selection. Based on MouseUp Reason Selection change (selected region change) can be considered as one. private void Model_SelectionChanged(object sender, GridSelectionChangedEventArgs e) { if(e.Reason == GridSelectionReason.MouseUp) { Console.WriteLine("Selected Range : "+e.Range); } } Best regards, Stanley

Administrator [Syncfusion]
Replied On February 7, 2006 12:21 PM

I put up a dialog in the SelectionChanging event saying: "Do you want to change selection?". If I leave e.Cancel = False, SelectionChanged never triggers with e.Reason = MouseUp.

stanleyj [Syncfusion]
Replied On February 8, 2006 02:18 AM

Hi Gergely, By default e.Cancel is false, so this should not be a problem. If you could post a sample we will analyze it here. Thanks, Stanley

Administrator [Syncfusion]
Replied On February 8, 2006 05:41 AM

Create a form, drag a GridControl on it and type the following code. You never get e.Reason = MouseUp. Private Sub GridControl1_SelectionChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventArgs) Handles GridControl1.SelectionChanged Debug.Print(e.Reason.ToString) End Sub Private Sub GridControl1_SelectionChanging(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridSelectionChangingEventArgs) Handles GridControl1.SelectionChanging e.Cancel = MessageBox.Show("Change selection?", "Question", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No End Sub

stanleyj [Syncfusion]
Replied On February 8, 2006 06:03 AM

Hi Gergely, The MouseUp will be hit only after MouseMove, so as to cover more than one cell to make it a selection. If you are looking for a check to be provided for every selection change, see if the code below helps. Private flag As Boolean = True Private Sub Model_SelectionChanging(ByVal sender As Object, ByVal e As GridSelectionChangingEventArgs) If flag Then If MessageBox.Show("Do you want to change selection?", "Question", MessageBoxButtons.YesNo)= DialogResult.Yes Then e.Cancel = False flag = False Else e.Cancel = True End If End If End Sub Private Sub Model_SelectionChanged(ByVal sender As Object, ByVal e As GridSelectionChangedEventArgs) If e.Reason = GridSelectionReason.MouseUp Then flag = True Console.WriteLine("SelectionChanged : " & e.Range) End If End Sub Regards, Stanley

Administrator [Syncfusion]
Replied On February 8, 2006 08:13 AM

I have a grid (list) of elements. I view the properties of selected elements in another control (property page). If no element is selected, I must disable the property page control. Possible use cases: 1. I select 1 or more rows in the grid: I enable the property page and view the corresponding properties (common properties if more rows selected). 2. I clear the selection: property page must be disabled. 3. I CHANGE the selection: user asked if he wants to change the selection and if Yes, property page must be updated with the new selection. But now it FLICKERS, because I cannot tell, if selection is only being cleared or it is a selection change, with a selection clear inbetween, because e.Reason = MouseUp does not come if I put up my dialog box. What I suggest: the GridControl should do multiple selection change actions between a BeginUpdate - EndUpdate frame and trigger BeginUpdateRequest-EndUpdateRequest events accordingly. So I can toggle a flag in the SelectionChanged event but do my stuff only in the EndUpdateRequest event.

stanleyj [Syncfusion]
Replied On February 13, 2006 06:22 AM

Hi Gergely, Sorry for the delayed reply. Can you upload the sample, we will work on it and get solution to it. Thanks, Stanley

Administrator [Syncfusion]
Replied On February 15, 2006 09:07 AM

The following small project should view the currently selected row''s index in a Label control. If nothing is selected, it must show "0". 1. Create a windows application with a form, insert a GridControl and a Label. 2. Set GridControl''s ListBoxSelectionMode to Multiextended. 3. Type the following code for the form: Private Sub GridControl1_SelectionChanging(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridSelectionChangingEventArgs) Handles GridControl1.SelectionChanging e.Cancel = MessageBox.Show("Change selection?", "Question", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No End Sub Private Sub GridControl1_SelectionChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventArgs) Handles GridControl1.SelectionChanged If e.Range.IsEmpty Then Me.Label1.Text = "0" Else Me.Label1.Text = e.Range.Top.ToString End If End Sub

stanleyj [Syncfusion]
Replied On February 16, 2006 12:12 AM

Hi Gergely, Please check this code below and see if it helps. Private Sub gridControl1_SelectionChanging(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridSelectionChangingEventArgs) e.Cancel = MessageBox.Show("Change selection?", "Question", MessageBoxButtons.YesNo) = DialogResult.No If e.Cancel Then Me.gridControl1.Selections.Clear() Me.label1.Text = "0" End If End Sub Private Sub gridControl1_SelectionChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventArgs) If (Not e.Range.IsEmpty) Then Me.label1.Text = e.Range.ToString() End If End Sub Best regards, Stanley

Administrator [Syncfusion]
Replied On February 16, 2006 09:14 AM

No, it does not help because if the user answers the "Do you want to change selection?" question with "No", he does not want to clear the selection but leave it as it was.

stanleyj [Syncfusion]
Replied On February 17, 2006 06:48 AM

Hi Gergely, What is the requirement here? I am not sure that I understand. Regards, Stanley >The following small project should view the currently selected row''s index in a Label control. If nothing is selected, it must show "0". > >1. Create a windows application with a form, insert a GridControl and a Label. > >2. Set GridControl''s ListBoxSelectionMode to Multiextended. > >3. Type the following code for the form: > Private Sub GridControl1_SelectionChanging(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridSelectionChangingEventArgs) Handles GridControl1.SelectionChanging > e.Cancel = MessageBox.Show("Change selection?", "Question", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No > End Sub > > Private Sub GridControl1_SelectionChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventArgs) Handles GridControl1.SelectionChanged > If e.Range.IsEmpty Then > Me.Label1.Text = "0" > Else > Me.Label1.Text = e.Range.Top.ToString > End If > End Sub >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;