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

Column Width

4 Answers 13 Views
CheckedListBox
This is a migrated thread and some comments may be shown as answers.
Martin Hamilton
Top achievements
Rank 1
Iron
Iron
Veteran
Martin Hamilton asked on 02 Apr 2021, 12:14 PM

I have a CheckedListBox with 3 columns.

But, I can't figure out how to set the width of each column even though I have used the code shown below;

    Private Sub BuildListBoxColumns()
        Dim nameColumn As New ListViewDetailColumn("Line Item Description")
        nameColumn.HeaderText = "Line Item Description"
        nameColumn.MinWidth = 800
        nameColumn.Width = 800
        Me.lbInvoiceItems.Columns.Add(nameColumn)
        Dim SKUColumn As New ListViewDetailColumn("SKU")
        SKUColumn.HeaderText = "SKU"
        SKUColumn.MinWidth = 120
        SKUColumn.Width = 120
        Me.lbInvoiceItems.Columns.Add(SKUColumn)
        Dim QtyColumn As New ListViewDetailColumn("Qty")
        QtyColumn.HeaderText = "Qty"
        QtyColumn.MinWidth = 80
        QtyColumn.Width = 100
        Me.lbInvoiceItems.Columns.Add(QtyColumn)
    End Sub

The MinWidth on each columns simply doesn't work.

How do I properly set the minwidth for each column?

it's probably something simple, but I cannot see why this isn't working

 

 

 

4 Answers, 1 is accepted

Sort by
0
Martin Hamilton
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 02 Apr 2021, 12:15 PM
And how does one set the column header alignment and cell alignment for the cell (column)?
0
Nadya
Telerik team
answered on 02 Apr 2021, 01:20 PM

Hello, Martin,

The MinWidth property specifies the minimum width that the column can be resized to. I tested this property locally and it is working fine. In your code snippet, you have 'Line Item Description' which has MinWidth=800. This means that you can resize this column more than 800px but you can not make it smaller than 800px. Please refer to the provided gif file that demonstrates this. The same behavior is observed with the other two columns from your setup. I am providing my test project for your reference. 

As to the other question, if you need to format cells in DetailsView you should handle the CellFormatting event and set the TextAlignment property for the cells.

I hope this information helps. Let me know if you have further questions.

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Martin Hamilton
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 02 Apr 2021, 01:57 PM

I guess the issue I'm seeing must be due to the CheckListBox being databound.

As you'll see in the images below - I cannot achieve the desired width.

is there a way that I can add a (AddRange) progrmatically to populate the rows/columns - it'll probably work if it's not databound?

Something along the lines of this?  This however doesn't work for me.

        'For Each myrow As DataRow In dtData.Rows
        '    lbInvoiceItems.Columns.AddRange(myrow("LineItemDesc"), myrow("SKU"), myrow("LineItemQty"))
        'Next

 

0
Nadya
Telerik team
answered on 05 Apr 2021, 11:11 AM

Hello, Martin,

With data-bound RadCheckedListBoxyou can specify the MinWidth of the columns as well. After setting the data source via the DataSource property you can access the desired columns either by index or name and set the MinWidth:

Public Sub New()
    InitializeComponent()

    Me.RadCheckedListBox1.DataSource = Me.CreateSimpleObjects()
    Me.RadCheckedListBox1.DisplayMember = "Name"
    Me.RadCheckedListBox1.ValueMember = "Id"
    Me.RadCheckedListBox1.CheckedMember = "CheckState"

    Me.RadCheckedListBox1.Columns(0).MinWidth = 300
    Me.RadCheckedListBox1.Columns(1).MinWidth = 300
    Me.RadCheckedListBox1.Columns(2).MinWidth = 300
End Sub

In case you have further difficulties, it would be greatly appreciated if you can provide more information about what is the exact goal that you are trying to achieve.

I hope this helps. Let me know if I can assist you further.

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
CheckedListBox
Asked by
Martin Hamilton
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Martin Hamilton
Top achievements
Rank 1
Iron
Iron
Veteran
Nadya
Telerik team
Share this question
or