To do this in gridcontrol, I can do a GridControl.ChangeCells with the selected cell ranges, then it will do the task. But in databoundgrid, it does not have the changecells method, how can I do this?
RC
Rajadurai C
Syncfusion Team
April 20, 2009 01:00 PM UTC
Hi Johnny,
Thanks for your interest in Syncfusion products.
In griddataboundgrid, the ChangeCells method can be invoked through the Model class.
this.gridDataBoundGrid1.Model.ChangeCells([args]);
Regards,
Rajadurai
JY
Johnny Yu
April 21, 2009 02:59 AM UTC
How come when I use the following code, when I click the tsbutton1, the contents in my selected cells disappeared instead of changing the borders to red color?
Private Sub ToolStripButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Dim range As GridRangeInfo
Dim style As New GridStyleInfo()
style.Borders.All = New GridBorder(GridBorderStyle.Solid, Color.Red, GridBorderWeight.Thin)
For Each range In Me.Griddbbound1.Selections.Ranges
Dim range1 As GridRangeInfo = Griddbbound1.Selections.Ranges.ActiveRange
Griddbbound1.Model.ChangeCells(GridRangeInfo.Cells(range1.Top, range1.Left, range1.Bottom, range1.Right), style)
Next range
End Sub
>Hi Johnny,
Thanks for your interest in Syncfusion products.
In griddataboundgrid, the ChangeCells method can be invoked through the Model class.
this.gridDataBoundGrid1.Model.ChangeCells([args]);
Regards,
Rajadurai
RC
Rajadurai C
Syncfusion Team
April 21, 2009 12:34 PM UTC
Hi Johnny,
Thanks for your update.
In griddataboundgrid, properties for the individual cell' styles other than Text, Cellvalue can be set only through cellspecific events like Model.QueryCellInfo, PrepareViewStyleInfo.
If you would like to set the border color for the selected range on button click, you can make use of the following code handled in QueryCellInfo event.
'boolean variable for setting border only to the selected ranges.
Dim b As Boolean = False
'QueryCellInfo event
Private Sub Model_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
If Me.gridDataBoundGrid1.Model.Selections.Ranges.AnyRangeIntersects(GridRangeInfo.Cell(e.RowIndex, e.ColIndex)) AndAlso b Then
e.Style.Borders.All = New GridBorder(GridBorderStyle.Solid, Color.Red, GridBorderWeight.Thin)
End If
If Me.gridDataBoundGrid1.Model.Selections.Ranges.Count = 0 Then
b = False
End If
End Sub
'Button click event
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
b = True
Me.gridDataBoundGrid1.Refresh()
End Sub
QueryCellInfo event get raised on each cell getting queried. The code attached above sets the border to the range of cells in selection range available in grid.
Regards,
Rajadurai