473,569 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making a very simple form

Hi,

I want to make a really simple form with C# and windows forms, which is
trivial with Java, but I'm unable to reproduce it with .NET. I can't
believe it's impossible.

I want a simple window with a textbox and a listbox below it. I don't
want to use fixed coordinates and sizes, since that's what layout
managers are for. I want the textbox and the listbox resize themselves
automatically if I resize the window. The textbox should resize only
horizontally (since the default height is okay) and the listbox should
resize both horizontally and vertically (it should fill all the
available space in the window below the textbox).

I used FlowLayoutPanel (I don't want to create a custom layout manager,
since this kind of form is really simpe) and added the two controls to
it. The controls appear, but they do not fill the window. What can the
problem be?
public class Myapp : Form
{
ListBox box = new ListBox();
TextBox text = new TextBox();
public Myapp()
{
FlowLayoutPanel panel = new FlowLayoutPanel ();
panel.FlowDirec tion = FlowDirection.T opDown;
panel.Dock = DockStyle.Fill;

panel.Controls. Add(text);
panel.Controls. Add(box);
Controls.Add(pa nel);

StartPosition = FormStartPositi on.CenterScreen ;
}

...

Oct 17 '06 #1
1 2975
sp************* **@gmail.com wrote:
I want a simple window with a textbox and a listbox below it. I don't
want to use fixed coordinates and sizes, since that's what layout
managers are for. I want the textbox and the listbox resize themselves
automatically if I resize the window. The textbox should resize only
horizontally (since the default height is okay) and the listbox should
Set the TextBox anchor property to Left,Right and clear the Top and
Bottom anchors. Then, whatever container the textbox is in, when the
container is resized, the textbox will be too, but only on the left and
right.
resize both horizontally and vertically (it should fill all the
available space in the window below the textbox).
You can set the ListBox Anchor property to Left,Top,Right, and Bottom
or Set the ListBox Dock property to Fill. It will then expand to take
up the remaining space.

Oct 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4157
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make regular expressions easier to create and use (and in my experience as a regular expression user, it makes them MUCH easier to create and use.) ...
19
6756
by: Christian Fowler | last post by:
I have a VERY LARGE pile of geographic data that I am importing into a database (db of choice is postgres, though may hop to oracle if necessary). The data is strictly hierarchical - each node has one, and only one parent. The depth should not exceed 6 or 7 levels. The initial import will have about 6 million leaves, and 3 million branches. I...
22
2541
by: tricard | last post by:
Good evening, I was thinking about making a very simple DOS based (console) menu for a project that i am working on, but I have no idea where to start for something like this. Does anyone have any resources they could point me to or shed some light on what it is that you do exactly. Like I said, I don't want a real complicated menu, just a...
5
2465
by: bsmith1111 | last post by:
I'm working on a simple calculator similar to the MS Calculator in visual c++ 6.0. I'm trying to teach myself the visual aspect of c++ on my own time, so I've decided to jump right into a program after reading through a lot of material that has gotten me familiar with it. I have a result edit box at the top of the window which holds whatever...
351
12839
by: CBFalconer | last post by:
We often find hidden, and totally unnecessary, assumptions being made in code. The following leans heavily on one particular example, which happens to be in C. However similar things can (and do) occur in any language. These assumptions are generally made because of familiarity with the language. As a non-code example, consider the idea...
84
15809
by: Peter Olcott | last post by:
Is there anyway of doing this besides making my own string from scratch? union AnyType { std::string String; double Number; };
204
4914
by: Masood | last post by:
I know that this topic may inflame the "C language Taleban", but is there any prospect of some of the neat features of C++ getting incorporated in C? No I am not talking out the OO stuff. I am talking about the non-OO stuff, that seems to be handled much more elegantly in C++, as compared to C. For example new & delete, references, consts,...
50
4436
by: Juha Nieminen | last post by:
I asked a long time ago in this group how to make a smart pointer which works with incomplete types. I got this answer (only relevant parts included): //------------------------------------------------------------------ template<typename Data_t> class SmartPointer { Data_t* data; void(*deleterFunc)(Data_t*);
10
5306
by: Jason | last post by:
I'm making a program that will convert decimal inputs (in this case, in inches) and output a fractional answer. At the moment, I'm only able to output the fractional answer in three parts: A whole number text box, a numerator text box, and a denominator text box. I realize that this is probably the closest I'll get to having fractions...
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.