I'm still evaluating the grid .... please bear with me .... :)
I have created a DataBoundGrid, whose datasource is a dataview of about 300 records.
I want to be able to selectively format the cells based on their contents. If I use the PrepareViewStyleInfo event the grid hangs.
I guess I'm using the wrong event - or am I using the wrong grid?
Private Sub GridDataBoundGrid1_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs) Handles GridDataBoundGrid1.PrepareViewStyleInfo
Dim dv As DataView = CType(Me.GridDataBoundGrid1.DataSource, DataView)
Dim drv As DataRowView = dv.Item(e.RowIndex)
Dim row As dsJFinancials.JournalRow = CType(drv.Row, dsJFinancials.JournalRow)
If row.Idnote = "C" Then
Me.GridDataBoundGrid1.GridBoundColumns("Ino").StyleInfo.TextColor = Color.Red
ElseIf row.Idnote = "D" Then
Me.GridDataBoundGrid1.GridBoundColumns("Ino").StyleInfo.TextColor = Color.Black
If row.RunningBalance < 0 Then
Me.GridDataBoundGrid1.GridBoundColumns("RunningBalance").StyleInfo.TextColor = Color.Red
Another question - I've created an XPToolBar, and added a ComboBoxBarItem - is there no way of providing a datasource and datamember for the ComboBoxBarItem.
One last question - I previously wrote a control which overrides the standard ComboBox. This control is used extensively through various projects. I want to replace it with your (far superior) ComboBoxExt. I tried writing a wrapper for the ComboBoxExt so that it would expose the native Combobox events, SelectedIndexChanged etc. Most of these events are avaialble in your ListControl, but there are many methods and events of the original ComboBox that your control do not expose, i.e. SelectedIndexChanged, SelectedValueChanged, DataSourceChanged, Items, etc.
While I would like in due course to upgrade my existing applications to use your controls, I would like to be able to do it gradually. Is there some way that I can map the original methods/events to your control, or would I have to change the source code (something I don't feel comfortable doing)?
Many thanks in advance
ADAdministrator Syncfusion Team April 15, 2003 02:09 PM
change your PrepareViewStyleInfo code so that it makes changes in the e.Style object and do not make changes to the grid. This would cause recursively calling this method otherwise:
Something like this should work:
if e.ColIndex = Me.GridDataBoundGrid1.NameToColIndex("Ino") then
If row.Idnote = "C" then
e.StyleInfo.TextColor = Color.Red
ElseIf row.Idnote = "D" Then
e.StyleInfo.TextColor = Color.Black
Regarding the ComboBoxExt. We actually wrote such a wrapper ourselves in the meantime. It will be available with the 1.6 version. That should help you more easily replace the ComboBox.
RPRamesh Praveen Syncfusion Team April 16, 2003 05:59 AM
Regarding the ComboBoxBarItem, is it the Text property that you want databound?
UNUnknown Syncfusion Team April 17, 2003 08:28 AM
1. Yes I want to bind to the text property. What I'm doing at the moment is looping through the datatable adding to the items (ChoiceList I think its called).
2. I adopted the code in Stephen's answer, but it does not pick up all the lines for formatting. The underlying data is a dataview of 220 rows and 20 columns ..... (after .... I just realized that e.rowindex = 0 is the header row!!)
3. I looked at the LinkLabelCellModel example which I understand. However, I would like to override the OnDraw of a GridBoundColumn, so that the user defined formatting occurs within the cell rather than in the PrepareViewStyleInfo event - however I can see no way of doing this.
The idea is that I would create a number of derived cell types with built in preformatting, i.e. if cellvalue <0 the style.textcolor=Red etc.
Is this possible, or am I barking up the wrong tree??
p.s. very close to taking a decision to purchase the suite :)
ADAdministrator Syncfusion Team April 17, 2003 09:37 AM
2) PrepareViewStyleInfo should be hit anytime a cell is drawn on the screen. So, any visible cell should be formatted as you specify in PrepareViewStyleInfo. Are you expecting cells that haven't been drawn (or are not currently visible) to be formatted? What do you mean by it does not pick up all the rows?
3) There is no drawing it the GridBoundColumn. The CellRenderer is responsible for drawing ths cell. So, you could derive a cell control (a CellModel and a CellRenderer), override the renderer's Draw method, and do your formatting there. Then you would make the GridBoundColumn.StyleInfo.CellType use your custom cell type.
A simpler option is to use 1.6 release'e QueryCellFormattedText event to format the text through an event. This is one of several new events exposed in that release.
UNUnknown Syncfusion Team April 17, 2003 09:47 AM
I realized later that I hadn't understood that e.rowindex = 0 refers to the header row - therefore it seemed that it wasn't picking up the data correctly, i.e.
Dim row As dsJFinancials.JournalRow = CType(CType(Me.GridDataBoundGrid1.DataSource, DataView).Item(e.RowIndex).Row, dsJFinancials.JournalRow)
was picking up the wrong row - it should be ...Item(e.RowIndex-1).Row
Anyway - not a problem any more.
I'm going off to purchase the suite now.
Many thanks for your amazing support here.
RPRamesh Praveen Syncfusion Team April 17, 2003 12:12 PM
1) Yes, there is no built-in data-binding support for the comboboxbaritem's choicelist. I will make this a feature request for a later release. The complexity is because comboboxbaritem is not a control derived class.