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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Evaluating Grid (again)

Thread ID:





3877 Apr 15,2003 05:27 PM UTC Apr 17,2003 05:12 PM UTC WinForms 6
Tags: GridControl
Jeremy Holt
Asked On April 15, 2003 05:27 PM UTC

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 End If If row.RunningBalance < 0 Then Me.GridDataBoundGrid1.GridBoundColumns("RunningBalance").StyleInfo.TextColor = Color.Red End If End Sub 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 Jeremy Holt

Administrator [Syncfusion]
Replied On April 15, 2003 07:09 PM UTC

Hi Jeremy, 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 End If etc. 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. Stefan

Ramesh Praveen [Syncfusion]
Replied On April 16, 2003 10:59 AM UTC

Hi, Regarding the ComboBoxBarItem, is it the Text property that you want databound? Regards, Praveen Ramesh

Jeremy Holt
Replied On April 17, 2003 01:28 PM UTC

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?? Many thanks Jeremy p.s. very close to taking a decision to purchase the suite :)

Administrator [Syncfusion]
Replied On April 17, 2003 02:37 PM UTC

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.

Jeremy Holt
Replied On April 17, 2003 02:47 PM UTC

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. Regards Jeremy

Ramesh Praveen [Syncfusion]
Replied On April 17, 2003 05:12 PM UTC

Jeremy, 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. Regards, Praveen


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon