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

change border color of selected cells in griddataboundgrid

Thread ID:

Created:

Updated:

Platform:

Replies:

80633 Apr 20,2009 09:13 AM UTC Apr 21,2009 12:34 PM UTC Windows Forms 3
loading
Tags: GridControl
Johnny Yu
Asked On April 20, 2009 09:13 AM UTC

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?


Rajadurai C [Syncfusion]
Replied On 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


Johnny Yu
Replied On 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




Rajadurai C [Syncfusion]
Replied On 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


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

;