I'm using 2009 Q3 Winforms. In order to create a multi-select dropdown combobox, I used a few other forum posts' responses as a guide. I created a GridMenuItem class that inherited from RadMenuItemBase and implemented INotifyPropertyChanged. That GridMenuItem contains a RadGridView and adds that GridView as a RadHostItem to its children.
Anyway, what happens is that the dropdown grid will resize itself each time you drop it down. It appears to be decreasing the height while increasing the width, by a small amount (I think around 6 both ways). Eventually you get to an ever-increasing line. I cannot seem to figure out what is wrong.
Below is the code to show what is happening.
Thoughts?
(Create a new Forms project with Form1, add a dropdown button)
Anyway, what happens is that the dropdown grid will resize itself each time you drop it down. It appears to be decreasing the height while increasing the width, by a small amount (I think around 6 both ways). Eventually you get to an ever-increasing line. I cannot seem to figure out what is wrong.
Below is the code to show what is happening.
Thoughts?
(Create a new Forms project with Form1, add a dropdown button)
Imports Telerik.WinControls |
Imports Telerik.WinControls.UI |
Imports System.Text |
Imports System.Data.Common |
Imports System.ComponentModel |
Public Class Form1 |
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
Dim Item As GridMenuItem = New GridMenuItem |
Dim Grid As RadGridView = Item.Grid |
Grid.Columns.Add(New GridViewDataColumn("A")) |
Grid.Columns.Add(New GridViewDataColumn("b")) |
Grid.Columns.Add(New GridViewDataColumn("c")) |
Grid.Rows.Add("Hello", "World", "!") |
Grid.Rows.Add("Hello", "World", "!") |
Grid.Rows.Add("Hello", "World", "!") |
Grid.ReadOnly = False |
Grid.Columns(0).Width = 5 |
Grid.Columns(1).ReadOnly = True |
Grid.Columns(2).IsVisible = False |
RadDropDownButton1.Items.Clear() |
RadDropDownButton1.Items.Add(Item) |
End Sub |
End Class |
Here's the item:
Imports Telerik.WinControls.UI |
Imports Telerik.WinControls |
Imports System.ComponentModel |
Public Class GridMenuItem |
Inherits RadMenuItemBase |
Implements INotifyPropertyChanged |
Dim _Grid As RadGridView |
Dim _HostItem As RadHostItem |
Public ReadOnly Property Grid() As RadGridView |
Get |
Return Me._Grid |
End Get |
End Property |
Protected Overrides Sub CreateChildElements() |
_Grid = New RadGridView() |
_Grid.BeginInit() |
_Grid.BindingContext = New BindingContext() |
_Grid.MultiSelect = True |
_Grid.AutoSize = False |
_Grid.HideColumnChooser() |
_Grid.ReadOnly = False |
_Grid.ShowGroupPanel = False |
_Grid.ShowNoDataText = False |
Dim Template As GridViewTemplate = _Grid.MasterGridViewTemplate |
Template.AllowCellContextMenu = False |
Template.AllowColumnChooser = False |
Template.AllowColumnHeaderContextMenu = False |
Template.AllowColumnReorder = False |
Template.AllowAddNewRow = False |
Template.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill |
Template.EnableGrouping = False |
Template.ShowFilteringRow = False |
Template.ShowRowHeaderColumn = False |
Template.ShowColumnHeaders = False |
_Grid.EndInit() |
_HostItem = New RadHostItem(_Grid) |
Me.Children.Add(_HostItem) |
End Sub |
Protected Overrides Function MeasureOverride(ByVal availableSize As System.Drawing.SizeF) As System.Drawing.SizeF |
Dim size As System.Drawing.SizeF = MyBase.MeasureOverride(availableSize) |
Return _Grid.Size |
End Function |
End Class |