Hello,
I have one column in my Grid which is setup to use an inherited GridComboBoxCellModel.
Using this causes CPU usage to go to 100%, taking it out results in normal levels of CPU usage.
Is there a known issue with performance or something I should be doing. Here are some code snippets of the usage and the actual inherited GridComboBoxCellModel
Usage:
---------
Dim selectableCellModel As New SelectableItemComboBoxCellModel(_timeSheetGrid.Model, leafItemValues)
selectableCellModel.BeepWhenNotSelectable = True
_timeSheetGrid.CellModels.Add("SelectableItemComboBoxCell", selectableCellModel)
Implementation:
----------------
Option Strict On
Option Explicit On
Imports Syncfusion.Windows.Forms
Imports Syncfusion.Windows.Forms.Grid
Imports System
Imports System.Runtime.Serialization
Public Class SelectableItemComboBoxCellModel
Inherits Syncfusion.Windows.Forms.Grid.GridComboBoxCellModel
Private _permissableValues As ArrayList
Private _beepWhenNotSelectable As Boolean
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New(info, context)
End Sub
Public Sub New(ByVal grid As GridModel, ByVal permissableValues As ArrayList)
MyBase.New(grid)
_permissableValues = permissableValues
End Sub
Public Overloads Overrides Function CreateRenderer(ByVal control As GridControlBase) As GridCellRendererBase
Return New SelectableItemComboBoxCellRenderer(control, Me, _permissableValues)
End Function
Public Property BeepWhenNotSelectable() As Boolean
Get
Return _beepWhenNotSelectable
End Get
Set(ByVal Value As Boolean)
_beepWhenNotSelectable = Value
End Set
End Property
End Class
Public Class SelectableItemComboBoxCellRenderer
Inherits GridComboBoxCellRenderer
Private _oldValue As Object
Private _permissableValues As ArrayList
Public Sub New(ByVal grid As GridControlBase, ByVal cellModel As GridCellModelBase, ByVal permissableValues As ArrayList)
MyBase.New(grid, cellModel)
_permissableValues = permissableValues
End Sub
Protected Overrides Sub OnShowDropDown()
_oldValue = ControlValue
MyBase.OnShowDropDown()
End Sub ''OnShowDropDown
Protected Overrides Sub OnCloseDropDown(ByVal reason As PopupCloseType)
MyBase.OnCloseDropDown(reason)
Dim value As Object = Me.ControlValue
If Not _permissableValues.Contains(value) Then
ControlValue = _oldValue
If CType(Model, SelectableItemComboBoxCellModel).BeepWhenNotSelectable Then
Beep()
End If
End If
End Sub ''OnCloseDropDown
End Class
NZ
Nick Zdunic
April 20, 2005 05:18 AM UTC
Ok - I''ve isloated the problem. I''m passing in an ArrayList to the constructor of SelectableItemComboBoxCellModel
This is causing the CPU usage to go up - probably due to some marshalling issues.
I have solved the problem by copying an Array in instead.
>Hello,
>
>I have one column in my Grid which is setup to use an inherited GridComboBoxCellModel.
>
>Using this causes CPU usage to go to 100%, taking it out results in normal levels of CPU usage.
>
>Is there a known issue with performance or something I should be doing. Here are some code snippets of the usage and the actual inherited GridComboBoxCellModel
>
>Usage:
>---------
>
>Dim selectableCellModel As New SelectableItemComboBoxCellModel(_timeSheetGrid.Model, leafItemValues)
> selectableCellModel.BeepWhenNotSelectable = True
>_timeSheetGrid.CellModels.Add("SelectableItemComboBoxCell", selectableCellModel)
>
>Implementation:
>----------------
>
>Option Strict On
>Option Explicit On
>
>Imports Syncfusion.Windows.Forms
>Imports Syncfusion.Windows.Forms.Grid
>Imports System
>Imports System.Runtime.Serialization
>
>Public Class SelectableItemComboBoxCellModel
> Inherits Syncfusion.Windows.Forms.Grid.GridComboBoxCellModel
>
> Private _permissableValues As ArrayList
> Private _beepWhenNotSelectable As Boolean
>
> Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
> MyBase.New(info, context)
> End Sub
>
> Public Sub New(ByVal grid As GridModel, ByVal permissableValues As ArrayList)
> MyBase.New(grid)
> _permissableValues = permissableValues
> End Sub
>
> Public Overloads Overrides Function CreateRenderer(ByVal control As GridControlBase) As GridCellRendererBase
>
> Return New SelectableItemComboBoxCellRenderer(control, Me, _permissableValues)
>
> End Function
>
> Public Property BeepWhenNotSelectable() As Boolean
> Get
> Return _beepWhenNotSelectable
> End Get
> Set(ByVal Value As Boolean)
> _beepWhenNotSelectable = Value
> End Set
> End Property
>End Class
>
>Public Class SelectableItemComboBoxCellRenderer
> Inherits GridComboBoxCellRenderer
>
> Private _oldValue As Object
> Private _permissableValues As ArrayList
>
> Public Sub New(ByVal grid As GridControlBase, ByVal cellModel As GridCellModelBase, ByVal permissableValues As ArrayList)
> MyBase.New(grid, cellModel)
> _permissableValues = permissableValues
> End Sub
>
> Protected Overrides Sub OnShowDropDown()
> _oldValue = ControlValue
> MyBase.OnShowDropDown()
> End Sub ''OnShowDropDown
>
> Protected Overrides Sub OnCloseDropDown(ByVal reason As PopupCloseType)
> MyBase.OnCloseDropDown(reason)
> Dim value As Object = Me.ControlValue
> If Not _permissableValues.Contains(value) Then
> ControlValue = _oldValue
> If CType(Model, SelectableItemComboBoxCellModel).BeepWhenNotSelectable Then
> Beep()
> End If
> End If
> End Sub ''OnCloseDropDown
>
>End Class
>
NZ
Nick Zdunic
April 20, 2005 05:36 AM UTC
Ok - I''ve isolated the problem. I''m passing in an ArrayList to the constructor of SelectableItemComboBoxCellModel
This is causing the CPU usage to go up - probably due to some marshalling issues.
I''ve tried copying in an array of numbers and I thought it was Ok, but it wasn''t - CPU usage went up to 100%
>Hello,
>
>I have one column in my Grid which is setup to use an inherited GridComboBoxCellModel.
>
>Using this causes CPU usage to go to 100%, taking it out results in normal levels of CPU usage.
>
>Is there a known issue with performance or something I should be doing. Here are some code snippets of the usage and the actual inherited GridComboBoxCellModel
>
>Usage:
>---------
>
>Dim selectableCellModel As New SelectableItemComboBoxCellModel(_timeSheetGrid.Model, leafItemValues)
> selectableCellModel.BeepWhenNotSelectable = True
>_timeSheetGrid.CellModels.Add("SelectableItemComboBoxCell", selectableCellModel)
>
>Implementation:
>----------------
>
>Option Strict On
>Option Explicit On
>
>Imports Syncfusion.Windows.Forms
>Imports Syncfusion.Windows.Forms.Grid
>Imports System
>Imports System.Runtime.Serialization
>
>Public Class SelectableItemComboBoxCellModel
> Inherits Syncfusion.Windows.Forms.Grid.GridComboBoxCellModel
>
> Private _permissableValues As ArrayList
> Private _beepWhenNotSelectable As Boolean
>
> Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
> MyBase.New(info, context)
> End Sub
>
> Public Sub New(ByVal grid As GridModel, ByVal permissableValues As ArrayList)
> MyBase.New(grid)
> _permissableValues = permissableValues
> End Sub
>
> Public Overloads Overrides Function CreateRenderer(ByVal control As GridControlBase) As GridCellRendererBase
>
> Return New SelectableItemComboBoxCellRenderer(control, Me, _permissableValues)
>
> End Function
>
> Public Property BeepWhenNotSelectable() As Boolean
> Get
> Return _beepWhenNotSelectable
> End Get
> Set(ByVal Value As Boolean)
> _beepWhenNotSelectable = Value
> End Set
> End Property
>End Class
>
>Public Class SelectableItemComboBoxCellRenderer
> Inherits GridComboBoxCellRenderer
>
> Private _oldValue As Object
> Private _permissableValues As ArrayList
>
> Public Sub New(ByVal grid As GridControlBase, ByVal cellModel As GridCellModelBase, ByVal permissableValues As ArrayList)
> MyBase.New(grid, cellModel)
> _permissableValues = permissableValues
> End Sub
>
> Protected Overrides Sub OnShowDropDown()
> _oldValue = ControlValue
> MyBase.OnShowDropDown()
> End Sub ''OnShowDropDown
>
> Protected Overrides Sub OnCloseDropDown(ByVal reason As PopupCloseType)
> MyBase.OnCloseDropDown(reason)
> Dim value As Object = Me.ControlValue
> If Not _permissableValues.Contains(value) Then
> ControlValue = _oldValue
> If CType(Model, SelectableItemComboBoxCellModel).BeepWhenNotSelectable Then
> Beep()
> End If
> End If
> End Sub ''OnCloseDropDown
>
>End Class
>
AD
Administrator
Syncfusion Team
April 20, 2005 09:29 AM UTC
I put your code in this little sample and I do not see the cpu hit you described.
http://www.syncfusion.com/Support/user/uploads/ComboBox_b4ad7b2f.zip
How many objects are in your permissible list? I assume that a very large list may take some cpu to do the look up.
Do you see any exceptions being displayed in your output window? That might cause such a hit.
NZ
Nick Zdunic
April 21, 2005 05:09 PM UTC
I''m using an Unbound grid, not a bound grid. Version 2.0.5.1
Your sample was against 3.0.1.0 and used a Bound Grid. Could this make a different.
The permitted items list has two items only.
No entries in the output window either.
>I put your code in this little sample and I do not see the cpu hit you described.
>
>http://www.syncfusion.com/Support/user/uploads/ComboBox_b4ad7b2f.zip
>
>
>How many objects are in your permissible list? I assume that a very large list may take some cpu to do the look up.
>
>Do you see any exceptions being displayed in your output window? That might cause such a hit.
AD
Administrator
Syncfusion Team
April 21, 2005 05:37 PM UTC
I change the sample I posted to work with a GridControl and still did not see the cpu problem. Below is the code.
Using 2051 may be part of this problem, but not sure. Can you try the sample code with your 2051 install? If you can reproduce teh problem in that sample, we can try to debug it here. (There was a performance issue with comboboxes in version 1.5 and VS2003, but that was fixed in 1.6.1.8.)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.GridControl1.ColCount = 4
Me.GridControl1.RowCount = 10
Dim i As Integer
Dim j As Integer
For i = 1 To Me.GridControl1.RowCount
For j = 1 To Me.GridControl1.ColCount
If j = 1 Then
Me.GridControl1(i, j).CellValue = i Mod 5
Else
Me.GridControl1(i, j).Text = String.Format("row{0} col{1}", i, j)
End If
Next
Next
Dim dt1 As New DataTable("ComboTable")
dt1.Columns.Add(New DataColumn("Value", GetType(Integer)))
For i = 0 To 5
Dim dr As DataRow = dt1.NewRow()
dr(0) = i
dt1.Rows.Add(dr)
Next
Dim al As New ArrayList
For i = 0 To 20
al.Add(i)
Next
Dim selectableCellModel As New SelectableItemComboBoxCellModel(GridControl1.Model, al)
selectableCellModel.BeepWhenNotSelectable = True
GridControl1.Model.CellModels.Add("SelectableItemComboBoxCell", selectableCellModel)
Dim style As GridStyleInfo = Me.GridControl1.ColStyles(1)
style.CellType = "SelectableItemComboBoxCell"
style.DataSource = dt1
style.DisplayMember = "Value"
style.ValueMember = "Value"
style.CellValueType = GetType(Integer)
End Sub
NZ
Nick Zdunic
April 22, 2005 07:11 AM UTC
I''ve tried the sample code and it''s Ok - but still alot less complicated than my form.
I''ve investigated a little more. When my application starts the form in question is loaded. CPU usage is OK. When I resize the MDIContainer form holding the form in question - that''s when the CPU usage goes haywire. In fact it happens whenever I switch to another application and then come back therefore requiring a repaint.
There are plenty of other events on the grid so need to keep looking. Any more ideas on what could be causing it.
>I change the sample I posted to work with a GridControl and still did not see the cpu problem. Below is the code.
>
>Using 2051 may be part of this problem, but not sure. Can you try the sample code with your 2051 install? If you can reproduce teh problem in that sample, we can try to debug it here. (There was a performance issue with comboboxes in version 1.5 and VS2003, but that was fixed in 1.6.1.8.)
>
>
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
>
> Me.GridControl1.ColCount = 4
> Me.GridControl1.RowCount = 10
> Dim i As Integer
> Dim j As Integer
>
> For i = 1 To Me.GridControl1.RowCount
> For j = 1 To Me.GridControl1.ColCount
> If j = 1 Then
> Me.GridControl1(i, j).CellValue = i Mod 5
> Else
> Me.GridControl1(i, j).Text = String.Format("row{0} col{1}", i, j)
> End If
>
> Next
> Next
>
>
> Dim dt1 As New DataTable("ComboTable")
> dt1.Columns.Add(New DataColumn("Value", GetType(Integer)))
> For i = 0 To 5
> Dim dr As DataRow = dt1.NewRow()
> dr(0) = i
> dt1.Rows.Add(dr)
> Next
>
> Dim al As New ArrayList
> For i = 0 To 20
> al.Add(i)
> Next
>
> Dim selectableCellModel As New SelectableItemComboBoxCellModel(GridControl1.Model, al)
> selectableCellModel.BeepWhenNotSelectable = True
> GridControl1.Model.CellModels.Add("SelectableItemComboBoxCell", selectableCellModel)
>
>
> Dim style As GridStyleInfo = Me.GridControl1.ColStyles(1)
> style.CellType = "SelectableItemComboBoxCell"
> style.DataSource = dt1
> style.DisplayMember = "Value"
> style.ValueMember = "Value"
> style.CellValueType = GetType(Integer)
>
>
> End Sub
>
NZ
Nick Zdunic
April 22, 2005 08:05 AM UTC
I''ve found the offending piece of code. When I comment out this block it CPU usage is fine:
With .Item(row, TOTAL_COLUMN)
.CellType = "FormulaCell"
.Text = String.Format("=C{0}+D{0}+E{0}+F{0}+G{0}+H{0}+I{0}", row, row, row, row, row, row, row)
.Format = NUMBER_FORMAT
.HorizontalAlignment = GridHorizontalAlignment.Right
.Font.Bold = True
.ReadOnly = True
End With
Is there a issue with formulas?
I might just have to populate the cell myself.
AD
Administrator
Syncfusion Team
April 22, 2005 08:15 AM UTC
Is that code just hit once when the grid is initially populated, or do you have it in an event like QueryCellInfo?
There were problems with formula cells in earlier versions where the FormulaTag was not being saved properly in SaveCellInfo. This would lead a problem like you describe.
Unless you are trying to use formulas in a virtual grid, this problem has been fixed in later releases. If you are trying to use formulas in a virtual grid, then your SaveCellInfo code will have to save the FormulaTag in some data cache you maintain, and your QueryCellInfo code would have to set the cached FormulaTag into the e.Style.FormulaTag (just like setting value).
NZ
Nick Zdunic
April 22, 2005 08:23 AM UTC
I''m doing the calculation myself. Seems to be the safe option at this point.
I''m not using QueryCellInfo/SaveCellInfo in this grid.
>Is that code just hit once when the grid is initially populated, or do you have it in an event like QueryCellInfo?
>
>There were problems with formula cells in earlier versions where the FormulaTag was not being saved properly in SaveCellInfo. This would lead a problem like you describe.
>
>Unless you are trying to use formulas in a virtual grid, this problem has been fixed in later releases. If you are trying to use formulas in a virtual grid, then your SaveCellInfo code will have to save the FormulaTag in some data cache you maintain, and your QueryCellInfo code would have to set the cached FormulaTag into the e.Style.FormulaTag (just like setting value).
CB
Cody Barnes
August 18, 2005 05:58 PM UTC
I''ve run into this as well. Perhaps a telling symptom of the problem can be demonstrated by making the formula "=RAND()". When the grid is viewed, the value of that cell constantly updates with a new number each time.
AD
Administrator
Syncfusion Team
August 18, 2005 06:12 PM UTC
What kind of grid are you using?
If it is a GridDataBoundGrid or a virtual GridControl, then you will need to use the technique illustrated in this KB to avoid the formulas constantly being recomputed.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=104