This is a migrated thread and some comments may be shown as answers.

[Solved] Preventing Selection

2 Answers 184 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
david ocasio
Top achievements
Rank 1
david ocasio asked on 14 Oct 2009, 01:16 PM
Is there a way to prevent a row or cell for that matter from being selected.
effectivly turning off selection for the entire grid.

I was hoping for a IsSelectionAllowed property but i dont see one.
I have tried clearing the selection (.SelectedItems.Clear() )  on the selectionChanged event
but that caused observable collection errors.
--> Cannot change ObservableCollection during a CollectionChanged or PropertyChanged event

thanks
dco

2 Answers, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 14 Oct 2009, 02:57 PM
Hi david ocasio,

For the time being the selection logic cannot be turned of but you can indeed clear the selection when a row is selected.

public Page()
{
    InitializeComponent();
  
    this.RadGridView1.ItemsSource = GetMessages();
    this.RadGridView1.SelectionChanged += new EventHandler<SelectionChangeEventArgs>(RadGridView1_SelectionChanged);
}
  
private bool changingSelection = false;
  
void RadGridView1_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
{
    if (changingSelection)
        return;
  
    changingSelection = true;
    this.RadGridView1.SelectedItems.Clear();
    changingSelection = false;
}

Hope this helps.

Sincerely yours,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
david ocasio
Top achievements
Rank 1
answered on 14 Oct 2009, 05:30 PM
oh i see

since i was clearing the selected items
the selection changed triggered again

that works
thanks
dco
Tags
GridView
Asked by
david ocasio
Top achievements
Rank 1
Answers by
Milan
Telerik team
david ocasio
Top achievements
Rank 1
Share this question
or