Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Day to Everyone especially to my Mentor Sir. Sergey. :)

I have finished my program called Record Management System,now i Just wanna make it Beautiful by improving this in Design and Functions.

Before i ask questions i just wanna say i don't own anything.

My Questions
1.I have my code on how to generate a label while running a program (size,color,font etc.)
My questions is how to generate a label that when i generate a label again and again that last created label will move down.

2.How can i Transfer the text inside my textbox to the text of my label in also set of words in it?
Ex. Textbox1.text = Label1.text
Label1.text = "Hello My name is,"Textbox1.text""
but seems that it only wrong.

3.When i generate the labels how can I maintain this labels in their position? can i put this on a Panel? if Yes i want that it will not exceed to my form its just only on the panel.

(All on my Questions are based on what i See on the Right Upper side of Facebook Wall)
(The Generating labels when any notifications happen)


And my last question is where can i find a website that gives me an example of vb.net program design or system designs.


Thank you and god bless.
Posted
Updated 5-Jun-13 16:33pm
v2
Comments
[no name] 5-Jun-13 22:45pm    
1. Going to depend on forms, web or WPF
2. Label1.text = "Hello My name is, " & Textbox1.Text
3. Have no idea what that even means.
Crixalis Paul 5-Jun-13 22:48pm    
I will make this in Vb.net windows Form
Sergey Alexandrovich Kryukov 6-Jun-13 0:03am    
Will you please add a tag "WinForms"? Tags will help you by making it easier for experts to locate proper question to reply before the question page is open. To improve your question (in this or other ways), click here.
—SA
Crixalis Paul 6-Jun-13 1:02am    
Im only just a simple student and Im new in programming world and yet I want kinds of program that looks hard to be created.

It makes me shy if my menthor.Sie Sergey KNOWS ABOUT it

i dont know how to code it pls healp.
TY :(

Here are my answers:

  1. Something like this:

    Choose some spacing integer value, such as ySpacer, declare it explicitly as a constant. Create a method for creating just one label with parameters, like text and location, returning the reference to a newly created label. First create one to be used as a sample. From an obtained label reference, take its height = sampleLabel.Height. For a next label, shift its x-location by (height + ySpacer) * n, where n is the number of the label, starting from zero.

    More accurately: you don't need a specially label sample, because when you just created a label, even before it is inserted in the parent control, it already has a correct height (which is actually defined when you set its font). So, you can set its Top based in its own height.
  2. The answer by ThePhantomUpvoter on this item is correct, but it's not so suitable if you have more than one parameter to be inserted in your text. This is because strings are immutable, so repeated concatenation will be very inefficient (do I need to explain why?) and the code purely readable and awkward to write.

    So, use string.Format instead:
    C#
    myLabel.Text = string.Format("Hello. My name is {0}", myTextBox.Text);
    Please see:
    http://msdn.microsoft.com/en-us/library/system.string.format.aspx[^].
  3. You don't need to maintain the positions of controls in response to events like resizing. Instead, you should design the layout the way it is done automatically and the UI is tolerant to the change in form size. Best way to do it is to base your layout on hierarchy of panels, with all controls docked with the use of the properties Control.Dock and Control.Padding.

    Please see my past answers on this topic:
    Zom Out malfunctions when Screen resolution changes[^],
    how to dock button so that it can adjust with the form[^] (you will find a simple code sample here).


Some general ideas on UI design: GUI Apperance - C#.Net[^].

[EDIT]

Some better ideas alternative to #1:

#1a: Instead of explicitly assigning location for a label or other control, use the specialized-layout panel, such as TableLayoutPanel:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx[^].

You will have to make such panel a parent of all your multiple items (or group if items, such as a label with labeled control). The child items might not be the labels directly, but a set of small panels (of the Panel type) each hosting a label and another control(s) with proper docking (see #3). It will also provide proper spacing between items.

#1b: I feel that you are trying to use those labels merely to provide a set of texts in your form. Actually, a label should be used almost exclusively to provide a key accelerator to some labeled control, which gets a keyboard focus when you hit Alt+SomeKey, where the key is defined by "&char..." placed in the label's text. If you don't use a label for labeling another control and an accelerator, you should think about using something else. In you case, if you just need a set of texts arranges one under another, you could be better off with… ListBox. You will be able to add/remove/modify any item at any time and never worry about their layout.

Good luck,
—SA
 
Share this answer
 
v3
Comments
Abhinav S 6-Jun-13 0:23am    
5.
Sergey Alexandrovich Kryukov 6-Jun-13 0:29am    
Thank you, Abhinav.
—SA
Crixalis Paul 6-Jun-13 0:50am    
5.
Sergey Alexandrovich Kryukov 6-Jun-13 1:00am    
Thank you. Hope it will help you.
I just added two more paragraphs — important!
—SA
Crixalis Paul 6-Jun-13 1:34am    
Im only just a simple student and Im new in programming world and yet I want kinds of program that looks hard to be created. It makes me shy if my menthor.Sie Sergey KNOWS ABOUT it i dont know how to code it pls healp. TY :(
You can simply set Label.Top = Label.Top - newLabel.Height;.
This way you keep moving labels down - you will have to put a limit on this as you will be limited by screen height.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Jun-13 0:22am    
Well, almost. This will make then positioned too close to each other... I voted 4 this time.
Please also see my answer to all 3 questions.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900