how to add blank row in multicolumncombobox windows

1 Answer 81 Views
MultiColumn ComboBox
Nandan
Top achievements
Rank 1
Iron
Iron
Iron
Nandan asked on 18 May 2022, 01:57 PM

HI

I want to show blank row at top of multicolumncombobox. My code is in vb.net

   Dim dr = dbManager.GetDataReader("SP_NewLotNo_Select", CommandType.StoredProcedure, parameters.ToArray(), connection)
        Dim dt As DataTable = New DataTable()

        dt.Load(dr)

        Try
            'Insert the Default Item to DataTable.
            Dim row As DataRow = dt.NewRow()
            row(0) = 0
            row(1) = "---Select---"
            dt.Rows.InsertAt(row, 0)

            'Assign DataTable as DataSource.
            cmbLotNo.DataSource = dt
            cmbLotNo.DisplayMember = "LotNumber"
            cmbLotNo.ValueMember = "NewLotId"

            cmbLotNo.Refresh()

            cmbLotNo.SelectedIndex = -1

            cmbLotNo.AutoCompleteMode = AutoCompleteMode.SuggestAppend
            cmbLotNo.AutoSizeDropDownToBestFit = False
            cmbLotNo.BestFitColumns(True, False)
            cmbLotNo.Columns(0).IsVisible = False
            cmbLotNo.Columns(3).TextAlignment = ContentAlignment.MiddleRight
            Me.cmbLotNo.AutoSizeDropDownToBestFit = True

            Me.cmbLotNo.AutoFilter = True
            Me.cmbLotNo.DisplayMember = "LotNumber"
            Dim filter As New FilterDescriptor()
            filter.PropertyName = Me.cmbLotNo.DisplayMember
            filter.Operator = FilterOperator.Contains
            Me.cmbLotNo.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
        Catch ex As Exception
            MessageBox.Show("Error:- " & ex.Message)
        Finally
            dr.Close()
            dbManager.CloseConnection(connection)
        End Try

its working but not perfectly as i want attaching image for output.

 

Thanks

 

Nandan

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 May 2022, 12:42 PM

Hello, Nandan,   

If you want to insert an empty item at the top of RadMultiColumnComboBox, you may use the following approach: 

    Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        Dim dt As New DataTable
        dt.Columns.Add("LotNumber", GetType(String))
        dt.Columns.Add("UserName", GetType(String))
        dt.Columns.Add("Melting%", GetType(Integer))

        dt.Rows.Add("2001", "Nandan", 75)
        dt.Rows.Add("2002", "Jay", 92)
        dt.Rows.Add("2003", "Jason", 88)
        dt.Rows.Add("2004", "Shruti", 80)


        'Insert the Default Item to DataTable.
        Dim row As DataRow = dt.NewRow()
        row(0) = 0
        row(1) = "" 
        dt.Rows.InsertAt(row, 0)
        Me.RadMultiColumnComboBox1.DataSource = dt
        Me.RadMultiColumnComboBox1.DisplayMember = "UserName"
        Me.RadMultiColumnComboBox1.ValueMember = "LotNumber"

        Me.RadMultiColumnComboBox1.SelectedIndex = -1

        Me.RadMultiColumnComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        Me.RadMultiColumnComboBox1.AutoSizeDropDownToBestFit = False
        Me.RadMultiColumnComboBox1.BestFitColumns(True, False)
        Me.RadMultiColumnComboBox1.Columns(0).IsVisible = False 
        Me.RadMultiColumnComboBox1.AutoSizeDropDownToBestFit = True


        Me.RadMultiColumnComboBox1.AutoFilter = True
        Me.RadMultiColumnComboBox1.DisplayMember = "UserName"
        Dim filter As New FilterDescriptor()
        filter.PropertyName = Me.RadMultiColumnComboBox1.DisplayMember
        filter.Operator = FilterOperator.Contains
        Me.RadMultiColumnComboBox1.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
    End Sub

Could you please specify what is the exact image output that you want to achieve?

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
MultiColumn ComboBox
Asked by
Nandan
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or