Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting Column Width in MultiColumn ListBox
#1
Hi Gintaras,
I am trying to figure out how to set column width in MultiColumn List Box.
I found this on MSDN
http://msdn.microsoft.com/en-us/library/...width.aspx

but don't know how to use that in QM.

Thanks for any help!

Stuart
#2
Don't remember. Maybe it is impossible. Look in MSDN, maybe there is a message or style.
#3
Hi Gintaras,

maybe I am closer to this then I realize...from the MSDN example I see

Quote:this.listBox1.ColumnWidth = 85

this is from a fuller description and example of ListBox properties from http://msdn.microsoft.com/en-us/library/...width.aspx that I have pasted below. I just don't know how to translate that into the style options that arise in the dialog screen....maybe this example will show me how to do it by myself in the future :oops:

truly thanks for any help and I understand if you are too busy at this time to help out.

S


from
Quote:.NET Framework Class Library
ListBox..::.ColumnWidth Property

Gets or sets the width of columns in a multicolumn ListBox.


Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Syntax
Visual Basic (Declaration)
Public Property ColumnWidth As IntegerVisual Basic (Usage)
Dim instance As ListBox
Dim value As Integer

value = instance.ColumnWidth

instance.ColumnWidth = valueC#
public int ColumnWidth { get; set; }Visual C++
public:
property int ColumnWidth {
int get ();
void set (int value);
}JScript
public function get ColumnWidth () : int
public function set ColumnWidth (value : int)
Property Value
Type: System..::.Int32
The width, in pixels, of each column in the control. The default is 0.

Exceptions
Exception Condition
ArgumentException A value less than zero is assigned to the property.


Remarks
If you set the value to zero (0), a default width is assigned to each column. If the ListBox is a multicolumn ListBox, this property returns the current width of each column in the list. You can use this property to ensure that each column in a multicolumn ListBox can properly display its items.

Examples
The following code example demonstrates a simple two-column ListBox.

Visual Basic Copy Code
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms

Public Class Form1
Inherits Form
Private listBox1 As ListBox


Public Sub New()
InitializeComponent()
End Sub

<STAThread()> _
Shared Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub

Private Sub InitializeComponent()
Me.listBox1 = New System.Windows.Forms.ListBox()
Me.SuspendLayout()
'
' listBox1
'
Me.listBox1.FormattingEnabled = True
Me.listBox1.HorizontalScrollbar = True
Me.listBox1.Items.AddRange(New Object() {"Item 1, column 1", "Item 2, column 1", "Item 3, column 1", "Item 4, column 1", "Item 5, column 1", "Item 1, column 2", "Item 2, column 2", "Item 3, column 2"})
Me.listBox1.Location = New System.Drawing.Point(0, 0)
Me.listBox1.MultiColumn = True
Me.listBox1.Name = "listBox1"
Me.listBox1.ScrollAlwaysVisible = True
Me.listBox1.Size = New System.Drawing.Size(120, 95)
Me.listBox1.TabIndex = 0
Me.listBox1.ColumnWidth = 85
'
' Form1
'
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(listBox1)
Me.Name = "Form1"
Me.ResumeLayout(False)
End Sub
End Class
C# Copy Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form
{
private ListBox listBox1;

public Form1()
{
InitializeComponent();
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}

private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.HorizontalScrollbar = true;
this.listBox1.Items.AddRange(new object[] {
"Item 1, column 1",
"Item 2, column 1",
"Item 3, column 1",
"Item 4, column 1",
"Item 5, column 1",
"Item 1, column 2",
"Item 2, column 2",
"Item 3, column 2"});
this.listBox1.Location = new System.Drawing.Point(0, 0);
this.listBox1.MultiColumn = true;
this.listBox1.Name = "listBox1";
this.listBox1.ScrollAlwaysVisible = true;
this.listBox1.Size = new System.Drawing.Size(120, 95);
this.listBox1.TabIndex = 0;
this.listBox1.ColumnWidth = 85;
//
// Form1
//
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.listBox1);
this.Name = "Form1";
this.ResumeLayout(false);

}
}

Platforms
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98



The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information
.NET Framework
Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

See Also
Reference
ListBox Class
ListBox Members
System.Windows.Forms Namespace
Tags : Add a tag Add Cancel Flag as ContentBug
#4
.NET code usually cannot be translated to QM.
#5
thanks Gintaras. What do you call the Win API code that QM "lives in" .... Win32? Is that a predecessor to .NET or is .NET something different altogether. Still trying to explain to people what "language" I am doing all my QM magic in!!!!!

thanks....Stuart

ps... the help in finding the changing .NET window controls was very helpful though!!!!
DotNetControls.qml [4.01 KiB]
[url]http://www.quickmacros.com/forum/viewtopic.php?p=16105
[/url]
#6
.NET wraps Windows API to make programming easier.


Forum Jump:


Users browsing this thread: 1 Guest(s)