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.
Syncfusion Feedback

How to set column width in GridListControl?

Thread ID:

Created:

Updated:

Platform:

Replies:

29461 May 25,2005 03:09 PM May 26,2005 09:35 AM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 25, 2005 03:09 PM

I have GridListControl whose DataSource is being set to a collection. After doing this, the columns appear to resize themselves to be able to display all data, but I can''t seem to resize the columns the way I want them to look. I found someone else asking a similar question in this thread: http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=29020 . However, the code example posted doesn''t work with Option Strict On. This line gives an error: Dim cr As GridDropDownGridListControlCellRenderer = cc.Renderer I tried to get around this with a CType(), but the object "cr" always appears to end up as Nothing. Am I missing something here?

Administrator [Syncfusion]
Replied On May 25, 2005 04:40 PM

The other code should be used only when a grid is using a GridListControl as a CellType, and only when the currentcell is one of these GridListControl CellTypes. Another way to get the renderer from a grid celltype is to use code like: Dim cr as GridDropDownGridListControlCellRenderer = CType(me.Grid.CellRenderers("GridListControl"), GridDropDownGridListControlCellRenderer) But if you just have a GridListControl1 stand-alone on a form, then you can use like this to set the colwidths. Me.gridListControl1.Grid.ColWidths(1) = 150

Administrator [Syncfusion]
Replied On May 25, 2005 05:20 PM

Okay, I tried the new "Dim cr..." line of code you recomended, and cr was successfully set to something. However, the QueryColWidth never appears to fire. This is, roughly, how my code looks (edited for simplicity). The owner of an instance of this class is meant to call the Populate method separately (it''s a little more complicated in my actual app), but I think that should affect anything. I''ve included it here just in case. Public Class SyncFusionGridCombobox Inherits Syncfusion.Windows.Forms.Tools.ComboBoxExt '' The grid that will be displayed in the dropdown list Public DropDownGrid As New GridListControl Protected cc As GridCurrentCell Protected cr As GridDropDownGridListControlCellRenderer Protected glc As GridListControl Public Sub New() cc = DropDownGrid.Grid.CurrentCell cr = CType(DropDownGrid.Grid.CellRenderers("GridListControl"), _ GridDropDownGridListControlCellRenderer) AddHandler cr.ListControlPart.Grid.QueryColWidth, _ AddressOf QueryColWidthHandler Me.ListControl = DropDownGrid Me.PopupControl = DropDownGrid End Sub Protected Sub QueryColWidthHandler(ByVal sender As Object, _ ByVal e As GridRowColSizeEventArgs) Console.WriteLine("QueryColWidth") End Sub Public Sub Populate() Dim myColl As CustomCollection '' Get a collection myColl = New CustomCollection '' Bind procedure collection to the grid DropDownGrid.DataSource = myColl DropDownGrid.DisplayMember = "Something" DropDownGrid.ValueMember = "SomethingElse" End Sub End Class The "cc =...","cr =...", and "AddHandler..." lines of code in the constructor seem to work fine, but it doesn''t look like QueryColWidth ever fires, since nothing is ever outputted to the Console window.

Administrator [Syncfusion]
Replied On May 25, 2005 07:51 PM

You are not using a GridDropDownGridListControlCellRenderer. This object is used in a GridControl or GridDataBoundGrid when you set a style.CellType = "GridListControl". You have a GridListControl being used as a dropdown in a ComboBoxExt. This is not using a GridDropDownGridListControlCellRenderer. In your case, you can just explicitly set the widths if you want to. But if you want to subscribe to the QueryColWidth event to manage this too. Here is a sample that shows how to do either. First, just drop the combobox and note the colwidths. Then click each button and then drop the combo again to see the effect. http://www.syncfusion.com/Support/user/uploads/GLC_In_Combobox_1323901a.zip

Administrator [Syncfusion]
Replied On May 26, 2005 09:35 AM

I swear, setting the ColWidths property was the first thing I tried, but it didn''t work. Now it does. Go figure.

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.

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

;