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. Image for the cookie policy date

Databoundgrid Celltype=Static not working on gridcontrollostfocus event

I am using Databound grid, i want to disble certain cells say cell 4,5 of a row when the user made some selection say cell 1,2 of the same row. I tryed these things: GridControl Lost focus event or CurrentcellValidating event I checked the value of cell 1,2 and made celltype of column 4,5 to static readonly=true is not working I tried gridboundgrid1(row,col).Enabled=False is also in those same events not working which is the correct place to fix the validation for enabling, disabling the cells Regards Rajaraman

3 Replies

AD Administrator Syncfusion Team March 7, 2003 07:28 AM UTC

You cannot use an indexer to set style properties (other than Text and CellValue) on an individual cell in a GridDataBoundGrid. The reason is that there are style properties saved for individual cells in a GridDataBoundGrid. The only 'storage' in a GriddataBoundGrid is the DataSource which only holds the values (hence why you can use indexers to save the Text/CellValue property). You can use indexers to save style properties for a GridControl, but not a GridDataBoundGrid. If you want to make a particular cell have a particular style property in a GridDataBoundGrid, then you should handle the Model.QueryCellInfo event. In your event handler, depending upon the value of e.ColIndex and e.RowIndex (and whatever other condition you want to use), you set the e.Style property accordingly. Here is a snippet that colors a row red if the value in column two on the row is 'red'.
'hook the handler say in FormLoad
AddHandler Me.GridDataBoundGrid1.Model.QueryCellInfo, AddressOf GridQueryCellInfo

'also set the grid to refresh the whole row as the current cell changes       Me.GridDataBoundGrid1.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow
Me.GridDataBoundGrid1.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow

'the handler
Private Sub GridQueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
	If e.ColIndex > 0 And e.RowIndex > 0 Then
		Dim colorRow As Boolean = False
		If e.ColIndex = 2 Then
			colorRow = (e.Style.Text = "red")
		Else
			colorRow = (Me.GridDataBoundGrid1(e.RowIndex, 2).Text = "red")
		End If
		If colorRow Then
			e.Style.BackColor = Color.Red
		End If
	End If
End Sub


RA Rajaraman March 14, 2003 03:18 AM UTC

Hi Clay, Received your tip got working partly. With this i can only check for a particular column upon receiving focus on that column. so first time, i recv the focus to the disabled cell. this i want to avoid. How can i go with? regards Rajaraman >You cannot use an indexer to set style properties (other than Text and CellValue) on an individual cell in a GridDataBoundGrid. The reason is that there are style properties saved for individual cells in a GridDataBoundGrid. The only 'storage' in a GriddataBoundGrid is the DataSource which only holds the values (hence why you can use indexers to save the Text/CellValue property). > > You can use indexers to save style properties for a GridControl, but not a GridDataBoundGrid. > > If you want to make a particular cell have a particular style property in a GridDataBoundGrid, then you should handle the Model.QueryCellInfo event. In your event handler, depending upon the value of e.ColIndex and e.RowIndex (and whatever other condition you want to use), you set the e.Style property accordingly. > > Here is a snippet that colors a row red if the value in column two on the row is 'red'. > >
> 'hook the handler say in FormLoad
> AddHandler Me.GridDataBoundGrid1.Model.QueryCellInfo, AddressOf GridQueryCellInfo
> 
> 'also set the grid to refresh the whole row as the current cell changes       Me.GridDataBoundGrid1.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow
> Me.GridDataBoundGrid1.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow
> 
> 'the handler
> Private Sub GridQueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
> 	If e.ColIndex > 0 And e.RowIndex > 0 Then
> 		Dim colorRow As Boolean = False
> 		If e.ColIndex = 2 Then
> 			colorRow = (e.Style.Text = "red")
> 		Else
> 			colorRow = (Me.GridDataBoundGrid1(e.RowIndex, 2).Text = "red")
> 		End If
> 		If colorRow Then
> 			e.Style.BackColor = Color.Red
> 		End If
> 	End If
> End Sub
> 


AD Administrator Syncfusion Team March 14, 2003 07:52 AM UTC

I am sorry, but I don't understand the problem you are describing? Can you explain it in more detail?

Loader.
Live Chat Icon For mobile
Up arrow icon