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

Overriding GridDataBound

Thread ID:

Created:

Updated:

Platform:

Replies:

3948 Apr 20,2003 09:50 AM Apr 21,2003 06:40 AM Windows Forms 2
loading
Tags: GridControl
Jeremy Holt
Asked On April 20, 2003 09:50 AM

In an overridden datagrid, I am overriding the DataSource property, so that on changing the source in design mode, the GridBoundColumns will automatically populate. The following code works fine Public Overrides Property DataSource() As Object Get Return _datasource End Get Set(ByVal Value As Object) _datasource = Value MyBase.DataSource = Value If Me.DesignMode AndAlso Not Value Is Nothing Then If Me.GridBoundColumns.Count = 0 Then If Value.GetType.IsSubclassOf(GetType(DataTable)) Then For Each dc As DataColumn In CType(Value, DataTable).Columns Dim gbc As New GridBoundColumn With gbc .MappingName = dc.ColumnName .HeaderText = dc.ColumnName .ReadOnly = dc.ReadOnly .StyleInfo.CellValueType = dc.DataType .Owner = Me.Binder If dc.DataType Is GetType(Date) Then .StyleInfo.CellType = "MonthCalendar" ElseIf dc.DataType Is GetType(Boolean) Then .StyleInfo.CellType = "CheckBox" .StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Center Else .StyleInfo.CellType = "TextBox" End If If dc.DataType Is GetType(Decimal) Or dc.DataType.GetType Is GetType(Double) Then .StyleInfo.Format = "#,##0.00;-#,##0.00;-" .StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right End If End With Me.GridBoundColumns.Add(gbc) Next End If End If End If End Set End Property However, I would like to be able to automatically set the "name" of the column, based on the MappingName, i.e. "col" & MappingName at the time that the column is added to the collection. How would I go about doing this? Many thanks in advance Jeremy

Administrator [Syncfusion]
Replied On April 20, 2003 02:15 PM

I am not sure I fully understand what you want. There is a GridDataBoundGrid.GridBoundColumns.CollectionChanged event you can try to catch to see if that will allow you to do what you want.

Jeremy Holt
Replied On April 21, 2003 06:40 AM

Clay I attach my attempt at overriding the grid. In the overridden Set DataSource property I have placed a comment to you better explaining what I'm trying to do. Many thanks Jeremy

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.

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.

;