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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Databoundgrid Celltype=Static not working on gridcontrollostfocus event

Thread ID:

Created:

Updated:

Platform:

Replies:

3180 Mar 7,2003 04:01 AM UTC Mar 14,2003 07:52 AM UTC WinForms 3
loading
Tags: GridControl
Rajaraman
Asked On March 7, 2003 04:01 AM UTC

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

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

Rajaraman
Replied On 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
> 

Administrator [Syncfusion]
Replied On 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?

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

;