This is a migrated thread and some comments may be shown as answers.

Bug in AllowResize

1 Answer 93 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Deborah
Top achievements
Rank 1
Deborah asked on 02 Jun 2011, 04:29 PM
I want my grid to fill to the full available size. I also don't want the user to be able to adjust the column widths. There is a bug in the grid that does not allow both of these features.

If you try the sample code below, you will see that the grid automatically fills to the available size. Then uncomment out the two "AllowResize" lines and you will see that the grid no longer automatically fills to the available size.

Is there a way to both fill and prevent the user from resizing the grid columns? THANKS

Imports Telerik.WinControls.UI
  
Public Class Form1
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim people As New List(Of Person) From {New Person(1, "Richard"), New Person(2, "Peter"), New Person(3, "Chris")}
  
        Me.radgridview1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
        Dim column1 As New GridViewTextBoxColumn("Column 1")
        'column1.AllowResize = False
  
        Dim column2 As New GridViewComboBoxColumn("Column 2")
        column2.Width = 100
        column2.FieldName = "Id"
        column2.DataSource = people
        column2.DisplayMember = "Name"
        column2.ValueMember = "Id"
        'column2.AllowResize = False
  
        Me.radgridview1.Columns.Add(column1)
        Me.radgridview1.Columns.Add(column2)
  
        ' Populate the cells
        Dim rowInfo As GridViewRowInfo = Me.radgridview1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A1"
        rowInfo.Cells(1).Value = 1
        rowInfo = Me.radgridview1.Rows.AddNew()
        rowInfo.Cells("A").Value = "A2"
        rowInfo.Cells("B").Value = 2
    End Sub
End Class
  
Public Class Person
  
    Public Sub New(ByVal Id As Integer, ByVal Name As String)
        Me.Name = Name
        Me.Id = Id
    End Sub
  
    Public Property Name As String
    Public Property Id As Integer
End Class

1 Answer, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 05 Jun 2011, 09:30 AM
Hello Deborah,

Have you tried
radGridView.AllowColumnResize = false;
?

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
Tags
GridView
Asked by
Deborah
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Share this question
or