Hello,
here is my solution :
I have created simple form application with only textBox1 on it,
the important thing is that the text box can change its dimensions in pixels using : textBox1.Width and textBox.Height initially it is 300 x 200 pixels
Also size of the text box will be changed by mouse click to open and mouse double click to close
code for MainForm.cs:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Test_app
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
textBox1.Multiline = false;
textBox1.Width = 300;
textBox1.Height = 20;
textBox1.Refresh();
}
void TextBox1MouseClick(object sender, MouseEventArgs e)
{
textBox1.Multiline = true;
textBox1.Width = 300;
textBox1.Height = 200;
textBox1.Refresh();
}
void TextBox1MouseDoubleClick(object sender, MouseEventArgs e)
{
textBox1.Multiline = false;
textBox1.Multiline = true;
textBox1.Width = 300;
textBox1.Height = 20;
textBox1.Refresh();
}
}
}
Right now it is possible to enter multiline text into only one line visible,
separating text lines with simply enter, and when you click to open all lines are there.Allso when you enter text lines into text box , and double click
the text box it closes, allso the first line is visible.
code for Program.cs:
/*
* Created by SharpDevelop.
* User: Peric Zeljko
* Date: 6.10.2011
* Time: 14:10
*
*/
using System;
using System.Windows.Forms;
namespace Test_app
{
/// <summary>
/// Class with program entry point.
/// </summary>
internal sealed class Program
{
/// <summary>
/// Program entry point.
/// </summary>
[STAThread]
private static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}
and code for MainForm.Designer.cs
/*
* Created by SharpDevelop.
* User: Peric Zeljko
* Date: 6.10.2011
* Time: 14:10
*
*/
namespace Test_app
{
partial class MainForm
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(3, 12);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(300, 200);
this.textBox1.TabIndex = 2;
this.textBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TextBox1MouseDoubleClick);
this.textBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.TextBox1MouseClick);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(348, 244);
this.Controls.Add(this.textBox1);
this.Name = "MainForm";
this.Text = "Test app";
this.ResumeLayout(false);
this.PerformLayout();
}
public System.Windows.Forms.TextBox textBox1;
}
}
I hope that this code would be enough to resolve your problem.
All the best,
Peric Zeljko
<removed>@yahoo.com