Amend column size on NominalGridLookup

SOLVED

Hi all,

I want to amend the grid inside a dropdown programmatically so the Name column is wide as soon at the form open.

But I am unable to get the grid inside it because its control is PopupTextBox+Dropdown which I cannot initiate in the code. Also the Dropdown class inside PopupTextBox is an internal class. 

Is there any way to do this?

  • 0

    Use the PopupOpened event - something like this:

    Public Class NominalPaymentReceiptForm
        'alter grid and popup columns
        Sub New(ByVal form As AmendableForm)
            Dim grid As Grid
            grid = CType(form.FindControlByName("nominalGrid").UnderlyingControl, Grid)
            grid.Columns(0).Width += 20
            grid.Columns(1).Width -= 10
            grid.Columns(2).Width -= 10
            grid.Columns(3).Width += 20
            grid.Columns(3).AutoSize = True
            Dim nominalGridLookup As Sage.MMS.Controls.NominalGridLookup
            nominalGridLookup = CType(form.FindControlByName("nominalGridLookup").UnderlyingControl, Sage.MMS.Controls.NominalGridLookup)
            AddHandler nominalGridLookup.PopupOpened, AddressOf NominalGridLookup_PopupOpened
        End Sub
        Private Sub NominalGridLookup_PopupOpened(ByVal sender As Object, ByVal args As Sage.Common.Controls.PopupOpenedEventArgs)
            If args.InvokeType = Sage.Common.Controls.InvokeType.Validate Then Exit Sub
            Dim list As List = CType(args.Form.Controls(0), List)
            list.Columns(0).Width = 70
            list.Columns(1).Width = 25
            list.Columns(2).Width = 25
            list.Columns(3).Width = 200
            list.Columns(4).Width = 50
        End Sub
    End Class

    By the way, are you aware of the Developers' forum? May be a better place for development queries like this - and rumour has it that development support may even look at it once in a while!

  • +1
    verified answer

    Yeah.  The easiest way to deal with this is to just increase the width of the drop-down; the 'Name' column is set to auto-size so it will stretch to fill the increased width.

    Just get hold of the NominalGridLookup in the usual way and add a handler to PopupOpened:

    private void NominalGridLookup_PopupOpened(object sender, Sage.Common.Controls.PopupOpenedEventArgs args)
    {
        if(args.Form != null)
        {
            args.Form.Width = 700;               
        }
    }

     If you really want to manipulate the columns then you can get at the list inside the drop-down form like this:

     var list = args.Form.Controls[0] as Sage.ObjectStore.Controls.List;

    ..and then you can get at the Columns collection of the List.

  • 0 in reply to Chris Burke

    thanks. just the way I need it in C#

  • 0 in reply to Geoff Turner

    thank you. I will have a look at the site. last time I went there no one answer my question so I thought the site is not active.