Hi Morten,
Thanks for your suggestion. Could you take a look at my code posted below
to see if you can suggest a change I might make to correct this problem?
The routine for computing the sizes of the four columns is
AdjustColumnWidths() at the bottom.
TIA,
Richard Muller
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Complex_FormWithSplitters
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class formCV : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabTechnologies;
private System.Windows.Forms.TabPage tabClients;
private System.Windows.Forms.TreeView treeView_Technologies;
private System.Windows.Forms.ListView listView_Clients;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public formCV()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.ListViewItem listViewItem1 = new
System.Windows.Forms.ListViewItem(new
System.Windows.Forms.ListViewItem.ListViewSubItem[] {
new System.Windows.Forms.ListViewItem.ListViewSubItem(null, "OCC",
System.Drawing.SystemColors.WindowText, System.Drawing.SystemColors.Window,
new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)))),
new System.Windows.Forms.ListViewItem.ListViewSubItem(null, "Shared National
Credits (SNC) "),
new System.Windows.Forms.ListViewItem.ListViewSubItem(null, "1999.10"),
new System.Windows.Forms.ListViewItem.ListViewSubItem(null,
"2000.10")}, -1);
System.Windows.Forms.ListViewItem listViewItem2 = new
System.Windows.Forms.ListViewItem(new string[] {
"Xerox",
"Xerox Dossier Publisher, a large client-server application",
"1997.10",
"1999.11"}, -1, System.Drawing.SystemColors.WindowText,
System.Drawing.SystemColors.Window, new System.Drawing.Font("Microsoft Sans
Serif", 8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))));
this.panel1 = new System.Windows.Forms.Panel();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabTechnologies = new System.Windows.Forms.TabPage();
this.treeView_Technologies = new System.Windows.Forms.TreeView();
this.tabClients = new System.Windows.Forms.TabPage();
this.listView_Clients = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.splitter1 = new System.Windows.Forms.Splitter();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.panel1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabTechnologies.SuspendLayout();
this.tabClients.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.tabControl1});
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 365);
this.panel1.TabIndex = 0;
//
// tabControl1
//
this.tabControl1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.tabTechnologies,
this.tabClients});
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(200, 365);
this.tabControl1.TabIndex = 0;
//
// tabTechnologies
//
this.tabTechnologies.Controls.AddRange(new System.Windows.Forms.Control[] {
this.treeView_Technologies});
this.tabTechnologies.Location = new System.Drawing.Point(4, 22);
this.tabTechnologies.Name = "tabTechnologies";
this.tabTechnologies.Size = new System.Drawing.Size(192, 339);
this.tabTechnologies.TabIndex = 0;
this.tabTechnologies.Text = "Technologies";
//
// treeView_Technologies
//
this.treeView_Technologies.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView_Technologies.ImageIndex = -1;
this.treeView_Technologies.Name = "treeView_Technologies";
this.treeView_Technologies.Nodes.AddRange(new
System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("C", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Project 1"),
new System.Windows.Forms.TreeNode("Project 2")}),
new System.Windows.Forms.TreeNode("C++", new System.Windows.Forms.TreeNode[]
{
new System.Windows.Forms.TreeNode("Project 1"),
new System.Windows.Forms.TreeNode("Project 2")}),
new System.Windows.Forms.TreeNode("Java"),
new System.Windows.Forms.TreeNode("Perl"),
new System.Windows.Forms.TreeNode("Ruby")});
this.treeView_Technologies.SelectedImageIndex = -1;
this.treeView_Technologies.Size = new System.Drawing.Size(192, 339);
this.treeView_Technologies.TabIndex = 0;
//
// tabClients
//
this.tabClients.Controls.AddRange(new System.Windows.Forms.Control[] {
this.listView_Clients});
this.tabClients.Location = new System.Drawing.Point(4, 22);
this.tabClients.Name = "tabClients";
this.tabClients.Size = new System.Drawing.Size(192, 339);
this.tabClients.TabIndex = 1;
this.tabClients.Text = "Clients";
//
// listView_Clients
//
this.listView_Clients.Columns.AddRange(new
System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4});
this.listView_Clients.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView_Clients.Items.AddRange(new System.Windows.Forms.ListViewItem[]
{
listViewItem1,
listViewItem2});
this.listView_Clients.Name = "listView_Clients";
this.listView_Clients.Size = new System.Drawing.Size(192, 339);
this.listView_Clients.TabIndex = 0;
this.listView_Clients.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Org. Name";
this.columnHeader1.Width = 90;
//
// columnHeader2
//
this.columnHeader2.Text = "From";
this.columnHeader2.Width = 90;
//
// columnHeader3
//
this.columnHeader3.Text = "To";
this.columnHeader3.Width = 30;
//
// columnHeader4
//
this.columnHeader4.Text = "Projects";
this.columnHeader4.Width = 30;
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(200, 0);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 365);
this.splitter1.TabIndex = 1;
this.splitter1.TabStop = false;
//
// richTextBox1
//
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Location = new System.Drawing.Point(203, 0);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(317, 365);
this.richTextBox1.TabIndex = 2;
this.richTextBox1.Text = "richTextBox1";
//
// formCV
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(520, 365);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.richTextBox1,
this.splitter1,
this.panel1});
this.Name = "formCV";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Curriculum Vitae";
this.panel1.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabTechnologies.ResumeLayout(false);
this.tabClients.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new formCV());
}
void AdjustColumnWidths()
{
//
// Adjust column widths based on control width
//
int iListViewWidth = this.listView_Clients.Width;
int[] aiWeights = new int[]{90, 90, 20, 20};
int[] aiWidth = new int[aiWeights.Length];
int iTotWeight = 0;
foreach (int n in aiWeights)
{
iTotWeight = iTotWeight + n;
}
int indx = 0;
for (int i=0; i<aiWeights.Length; i++)
{
int w = iListViewWidth * aiWeights / iTotWeight;
this.listView_Clients.Columns.Width = w;
}
}
}
}