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

GridDataBoundGrid - Unbound column 1st col - colwidth not working

Thread ID:





7301 Sep 19,2003 01:53 AM UTC Sep 19,2003 09:56 AM UTC WinForms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On September 19, 2003 01:53 AM UTC

Hi I want to set the column width of unbound column i tried in many ways (1) these are my code '----------Loading the column Me.gceDealView.BeginUpdate() ' Copy over bound columns and add one unbound extra column at the end Dim columns As GridBoundColumnsCollection = CType(gceDealView.Binder.InternalColumns.Clone(), GridBoundColumnsCollection) Dim unboundColumn As New GridBoundColumn() Dim extraColHeaders As Integer = 1 ''Dim style As New GridStyleInfo() ''gceDealView.Model.CellModels.Add("DragButton", New DragButtonCellModel(gceDealView.Model)) ''style.BaseStyle = "Standard" ''style.CellType = "DragButton" ''style.Description = "T" unboundColumn.HeaderText = "Y" unboundColumn.MappingName = "Unbound" unboundColumn.StyleInfo.AutoSize = True columns.Add(unboundColumn) gceDealView.Binder.GridBoundColumns = columns Me.gceDealView.Model.Cols.HeaderCount = extraColHeaders Me.gceDealView.Model.Cols.FrozenCount = extraColHeaders Me.gceDealView.Model.Data.ColCount = Me.gceDealView.Model.ColCount AddHandler gceDealView.Model.QueryCellInfo, AddressOf ModelQueryCellInfo gceDealView.Model.ColWidths(1) = 20 gceDealView.Binder.InternalColumns("Unbound").HeaderText = "Y" gceDealView.Model.ColWidths("Unbound") = 20 Me.gceDealView.EndUpdate() Me.gceDealView.Model.ColWidths.ResizeToFit(GridRangeInfo.Table, GridResizeToFitOptions.IncludeHeaders) ' gceDealView.Model.ColWidths(1) = 10 'gceDealView.Model.Cols.FrozenCount = 1 'this is here to hide an extra column at the end ???? 'remove when the problem is corrected... ' 'gceDealView.Model.Cols.Hidden(gceDealView.Model.ColCount) = True 'gceDealView.Model.ColWidths(0) = 10 '---------- 'Quercellinfo '------------ Private Sub ModelQueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs) Dim model As GridModel = CType(sender, IGridModelSource).Model Dim rowIndex As Integer = e.RowIndex If rowIndex > model.Rows.HeaderCount Then Dim colIndex As Integer = e.ColIndex 'Unbound checkbox header column If colIndex = 1 Then ' Initialize appearance of checkbox e.Style.CellType = "TextBox" 'e.Style.Interior = New BrushInfo(Color.FromArgb(192, 201, 219)) 'e.Style.Interior = New BrushInfo(GradientStyle.Horizontal, Color.FromArgb(192, 201, 219), Color.FromArgb(237, 240, 246)) 'e.Style.Borders.Right = New GridBorder(GridBorderStyle.Standard, Color.Gray, GridBorderWeight.Thin) 'e.Style.HorizontalAlignment = GridHorizontalAlignment.Left 'e.Style.VerticalAlignment = GridVerticalAlignment.Middle e.Style.Text = "" e.Style.ImageList = ImglstDealView e.Style.ImageIndex = 0 e.Style.Description = "*" e.Style.Font.Size = 8 e.Style.Font.Bold = False e.Handled = True ' Syncfusion.Diagnostics.TraceUtil.TraceCurrentMethodInfo(keyColIndex, key, value, e); Return End If 'Unbound column in columns collection Dim fieldNum As Integer = Me.gceDealView.Binder.ColIndexToField(colIndex) If fieldNum >= 0 Then Dim col As GridBoundColumn = Me.gceDealView.Binder.GridBoundColumns(fieldNum) If Not (col Is Nothing) AndAlso col.MappingName = "Unbound" Then 'Select Case rowIndex Mod 4 'e.Style.HorizontalAlignment = GridHorizontalAlignment.Left 'e.Style.VerticalAlignment = GridVerticalAlignment.Middle e.Style.CellType = "TextBox" e.Style.ImageList = ImglstDealView e.Style.ImageIndex = 0 e.Style.Text = "" e.Style.Description = "*" e.Style.Font.Size = 8 e.Style.Font.Bold = False e.Handled = True 'Syncfusion.Diagnostics.TraceUtil.TraceCurrentMethodInfo(keyColIndex, key, value, e); Return End If End If End If End Sub (2) i have tried to change colwidth in syncfusion sample at the end of the following snippet GDBGWithDropGrids sample has this code in Class GridHierDataBoundGrid --------------------------- 'this.Model.ColWidths.ResizeToFit(GridRangeInfo.Row(0)); 'set the width of th erow headers If hasChildGrid Then Me.Model.ColWidths(1) = 18 Me.Model.Cols.FrozenCount = 1 'this is here to hide an extra column at the end ???? 'remove when the problem is corrected... Me.Model.Cols.Hidden(Me.Model.ColCount) = True End If Me.Model.ColWidths(0) = 18 ------------------------------------- Both of the above efforts not working the first unbound column has some fixed column width and it can be altered manual after the screen gets loaded. what is the problem where i am missing Thanks Rajaraman

Administrator [Syncfusion]
Replied On September 19, 2003 09:56 AM UTC

You should try setting the gridDataBoundGrid1.AllowResizeToFit = false to see if this handles this problem for you. If you do not set this property, the grid tries to size things based on headertext, an dthis will step on your explicit sizing. Here is a link to a KB article on sizing columns in a GridDataBoundGrid. http://www.syncfusion.com/KB/Grid/Grid_c35c.asp#q577q


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

or the page will be automatically redirected to 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