ST
stanleyj
Syncfusion Team
January 18, 2006 09:30 AM UTC
Hi Wirawan,
Please try in gridDataBoundGrid1.Model.SelectionChanging / gridDataBoundGrid1.Model.SelectionChanged handler.
Best regards,
Stanley
IG
I Gusti Ngurah Wirawan
January 18, 2006 09:35 AM UTC
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
ST
stanleyj
Syncfusion Team
January 18, 2006 09:53 AM UTC
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
AD
Administrator
Syncfusion Team
February 7, 2006 05:21 PM UTC
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.
ST
stanleyj
Syncfusion Team
February 8, 2006 07:18 AM UTC
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
AD
Administrator
Syncfusion Team
February 8, 2006 10:41 AM UTC
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
ST
stanleyj
Syncfusion Team
February 8, 2006 11:03 AM UTC
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
AD
Administrator
Syncfusion Team
February 8, 2006 01:13 PM UTC
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.
ST
stanleyj
Syncfusion Team
February 13, 2006 11:22 AM UTC
Hi Gergely,
Sorry for the delayed reply.
Can you upload the sample, we will work on it and get solution to it.
Thanks,
Stanley
AD
Administrator
Syncfusion Team
February 15, 2006 02:07 PM UTC
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
ST
stanleyj
Syncfusion Team
February 16, 2006 05:12 AM UTC
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
AD
Administrator
Syncfusion Team
February 16, 2006 02:14 PM UTC
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.
ST
stanleyj
Syncfusion Team
February 17, 2006 11:48 AM UTC
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
>