Home › Forums › WinForms controls › Xceed Grid for WinForms › Don’t allow row selection
-
AuthorPosts
-
#13540 |
Hi.
I want display a grid all readonly.
The user can’t select cell, cant’ select rows…. can do nothing!
I want to show some information in the grid and select a row programmatically, based on some calculation.How can i do this?
Thanks.
Imported from legacy forums. Posted by Gian Luigi (had 725 views)
Try this:
– set the <b>AllowCellNavigation</b> property of the GridControl to <b>false</b>
– set the <b>SelectionMode</b> property of the GridControl to <b>SelectionMode.None</b>
– select a row programmatically, by setting the <b>IsSelected</b> property of the row to <b>true</b>Imported from legacy forums. Posted by Tommy (had 171 views)
Thanks Tommy for your answer.
I set the property you wrote, but if the user click on the grid the selection is cancelled.Here is a snippet from my Code:
In InitializeComponent:
‘
‘GridControl1
‘
Me.GridControl1.AllowCellNavigation = False
Me.GridControl1.DataRowTemplate = Me.dataRowTemplate1
Me.GridControl1.FixedHeaderRows.Add(Me.GroupByRow1)
Me.GridControl1.FixedHeaderRows.Add(Me.ColumnManagerRow1)
Me.GridControl1.Location = New System.Drawing.Point(88, 72)
Me.GridControl1.Name = “GridControl1”
‘
‘GridControl1.RowSelectorPane
‘
Me.GridControl1.RowSelectorPane.Visible = False
Me.GridControl1.SelectionMode = System.Windows.Forms.SelectionMode.None
Me.GridControl1.Size = New System.Drawing.Size(440, 176)
Me.GridControl1.TabIndex = 0————–
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If IsNothing(m_dtTab3) Then
m_dtTab3 = New DataTable
End If
m_dtTab3.Columns.Clear()
m_dtTab3.Columns.Add(“RapPercTab2”, GetType(System.String))
m_dtTab3.Columns.Add(“RapPercTab2Min”, GetType(System.Int16))
m_dtTab3.Columns.Add(“RapPercTab2Max”, GetType(System.Int16))
m_dtTab3.Columns.Add(“PercIncr3”, GetType(System.Decimal))Dim dr As DataRow
dr = m_dtTab3.NewRow
dr(“RapPercTab2Max”) = 50
dr(“RapPercTab2”) = “x <= ” & dr(“RapPercTab2Max”).ToString
dr(“PercIncr3”) = 0
m_dtTab3.Rows.Add(dr)
dr = m_dtTab3.NewRow
dr(“RapPercTab2Min”) = 50
dr(“RapPercTab2Max”) = 75
dr(“RapPercTab2”) = dr(“RapPercTab2Min”).ToString & ” < x <= ” & dr(“RapPercTab2Max”).ToString
dr(“PercIncr3”) = 10
m_dtTab3.Rows.Add(dr)
dr = m_dtTab3.NewRow
dr(“RapPercTab2Min”) = 75
dr(“RapPercTab2Max”) = 100
dr(“RapPercTab2”) = dr(“RapPercTab2Min”).ToString & ” < x <= ” & dr(“RapPercTab2Max”).ToString
dr(“PercIncr3”) = 20
m_dtTab3.Rows.Add(dr)
dr = m_dtTab3.NewRow
dr(“RapPercTab2Min”) = 100
dr(“RapPercTab2”) = “x > ” & dr(“RapPercTab2Min”).ToString
dr(“PercIncr3”) = 30
m_dtTab3.Rows.Add(dr)GridControl1.DataSource = m_dtTab3
GridControl1.DataRows(2).IsSelected = True
End SubImported from legacy forums. Posted by Gian Luigi (had 431 views)
You could catch the <b>IsSelectedChanged</b> event from the datarowtemplate, and in the event handler, you could check to see if the row can be selected. If the row can’t be selected, deselect it. Something like this:<code>Dim row As Xceed.Grid.Row = sender
If row.IsSelected Then
If row can not be selected Then ‘ fill in the right condition here
row.IsSelected = False
End If
End If</code>Imported from legacy forums. Posted by Tommy (had 3795 views)
-
AuthorPosts
- You must be logged in to reply to this topic.