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

multi column combobox resizing

2 Answers 368 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mihai Velicu
Top achievements
Rank 1
Mihai Velicu asked on 06 Apr 2010, 11:30 PM
Hi !

I have a grid and one of the column is multi column combo box. Everything works fine.
When I want to resize RadMultiColumnComboBoxElement, I found it particulary very hard.Is not working for example like rad grid in this code:
rdgv.MasterGridViewTemplate.BestFitColumns()

Practically I had to re size it manually.

This is my code and my question is ; Is any way to resize RadMultiColumnComboBoxElement like rad grid control, only specifying a property like BestFitColumns ?

My code for the grid and multicolumnComboBox column :

Private Sub ConfigureGridView(ByVal dtEmpJob As DataTable, ByVal dtListEmployees As DataTable)

        If dtEmpJob Is Nothing OrElse dtListEmployees Is Nothing Then
            Return
        End If

        rdgv.DataSource = dtEmpJob
        Me.rdgv.MasterGridViewTemplate.Columns("EmpNo").HeaderText = "Emp.No"
        Me.rdgv.MasterGridViewTemplate.Columns("Active").HeaderText = "Active"

        Dim col As GridViewDataColumn = TryCast(rdgv.MasterGridViewTemplate.Columns("EmpFullName"), GridViewDataColumn)

        If Not col Is Nothing Then
            rdgv.MasterGridViewTemplate.Columns.Remove(col)
        End If

        Dim col1 As GridViewMultiComboBoxColumn = New GridViewMultiComboBoxColumn
        col1.DataSource = dtListEmployees
        col1.DisplayMember = "EmpFullName"
        col1.ValueMember = "pEmployeeId"
        col1.FieldName = "EmpNo"
        col1.HeaderText = "Custom"
        rdgv.MasterGridViewTemplate.Columns.Add(col1)
        AddHandler rdgv.CellBeginEdit, AddressOf rdgv_CellBeginEdit

        rdgv.MasterGridViewTemplate.BestFitColumns()

        Me.rdgv.MasterGridViewTemplate.Columns("EmpNo").Index = 0
        Me.rdgv.MasterGridViewTemplate.Columns("EmpNo1").Index = 1
        Me.rdgv.MasterGridViewTemplate.Columns("Active").Index = 2
    End Sub


    Private isColumnAdded As Boolean
--------------------------------------the  CODE WHERE I HAD TO RESIZE MULTICOLUMN COMBOBOX----------------------------------------------
    Private Sub rdgv_CellBeginEdit(ByVal sender As Object, ByVal e As GridViewCellCancelEventArgs)
        If TypeOf Me.rdgv.CurrentColumn Is GridViewMultiComboBoxColumn Then
            If (Not isColumnAdded) Then
                isColumnAdded = True

                Dim multiColumnComboElement As RadMultiColumnComboBoxElement = CType(Me.rdgv.ActiveEditor, RadMultiColumnComboBoxElement)
                multiColumnComboElement.EditorControl.MasterGridViewTemplate.AutoGenerateColumns = False

                multiColumnComboElement.DropDownSizingMode = SizingMode.UpDownAndRightBottom
                multiColumnComboElement.DropDownMinSize = New Size(300, 100)

                Dim column As New GridViewTextBoxColumn("pEmployeeId")
                column.HeaderText = "Emp No"
                column.Width = 60
                multiColumnComboElement.Columns.Add(column)
                column = New GridViewTextBoxColumn("EmpFullName")
                column.HeaderText = "Employee"
                column.Width = 120
                multiColumnComboElement.Columns.Add(column)

                multiColumnComboElement.BestFitColumns()
                multiColumnComboElement.AutoSizeDropDownToBestFit = True

            End If
        End If
    End Sub


Regards,
Mihai








2 Answers, 1 is accepted

Sort by
0
Accepted
Martin Vasilev
Telerik team
answered on 09 Apr 2010, 04:36 PM
Hi Mihai Velicu,

Thank you for writing.

It seems that RadMultiColumnComboBoxElement.BestFitColumns method does not work in every situation. Please, try using the EditorControl.MasterGridViewTemplate.BestFitColumns instead:
 
Private Sub radGridView1_CellEditorInitialized(ByVal sender As Object, ByVal e As GridViewCellEventArgs)
    Dim element As RadMultiColumnComboBoxElement = TryCast(Me.radGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
    If e.ColumnIndex = 1 AndAlso element IsNot Nothing Then
        'element.BestFitColumns();
        element.EditorControl.MasterGridViewTemplate.BestFitColumns()
    End If
End Sub

Let me know if you still experience any difficulties.

Greetings,
Martin Vasilev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mihai Velicu
Top achievements
Rank 1
answered on 09 Apr 2010, 07:59 PM
Is working , Thank You !

Regards,
Mihai
Tags
GridView
Asked by
Mihai Velicu
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Mihai Velicu
Top achievements
Rank 1
Share this question
or