Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
http://i.stack.imgur.com/Hi9Iz.jpg
i am trying to create a table in c# which should look like at example above and it should be usable in a loop. example: i have two variables called "text" and "author" big box belongs to text and right bottom box belongs to author. those variables available in a loop. what i want to is fill those boxes and make it compatible with loop. i managed to solve this with textboxes but i couldn't figure out how to make them stay under another one.
The easier way (that i am aware of) to do what you want is with an usercontrols and a flowLayoutPanel so we do it as follow
Create an UserControl
create it with panels or textBox in the way you want your table to be, i did like so
Create a flowLayoutPanel
put it where you like it to be and set those properties
this.flowLayoutPanel1.AutoScroll = true;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.WrapContents = false;
add as much table like UserControl you want in it the result should be as follow
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am using Windows Forms .NET C# for this project
I am making a school project for a cafe ordering system. And the coffee aspect is a simple custom controller that allows users to pick out a size of the coffee, how many sugars and creams they want. My issue is that I then have to take that user control inputs and store them in the main form list and inside a ListBox as a display of an order.
Does anyone know how to store user control inputs into a main form List<>?
The best way is to create a class to store info about order, let's call it class "Order". Each order will be represented by instance of this class (you pass your control's values as parameters to the constructor). You can store orders in the List<Order>.
To add it to the ListBox, you must override ToString() method:
public override string ToString(){ return "onfo to show" }
This method will show info about order from your class in the way you like.
P.s. for more specific help provide sample code of what you have tried since now.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a List of objects and i want to create a Foreach loop which create images on my MainWindow separated by 50 pixels for example. I don't know if I have to create them in the desgner itself or if there's a way to create then place the images the one below the other in a command.
For example i have:
List<string> URIS = new List<string>();
foreach (var i in URIS)
{
//New image in MainWindow with source i
}
Remember that I want a "list" of images in my Window so that every image is below the last one.
Look into the ItemsControl. It has an ItemsSource property that takes a list and lays out its items into a visual list. You can use the ItemTemplate property to control exactly what type of visual is created from each list item, including things like spacing.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
if (Operators.CompareString(this.ParentForm.ActiveControl.Name, this.Name, false) == 0)
{
base.Focus();
}
From What I have experience in VB6,the above code doesn't work because they are never equal if the users didn't change to the same name.
From Example, the UserControl Name is ucCalendar, When I drag to my From, the name will automatically change to ucCalendar1,even though I can change to ucCalendar but usually we won't do that.
I think the coder want to compare whether the UserControl is the only control or ActiveControl on the Form so that he can force to focus it.
I don't know this C# works or not. Please tell me.
There is nothing in the WinForms code saying that two controls can not have the same name. The reason you think that is that you're looking at it from the designer perspective, when you use the designer it won't let you have two controls with the same name just because it uses there as field names for them in the code, and as you probably know there can not be two fields / properties / variables with the same name in the same scope. As a matter of fact there is no need for the Control's Name property to be anything.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
In my current project I want to implement a checkbox that, if checked, replaces all strings in labels, tabs, etc. currently being shown on a form with a different string.
For example, If checked, all instances of the word "car" would change to the word "truck" all through out the program.
I'd rather not go through a do a .replace on every single string in the code. I was wondering if there was some way to "intercept" output strings and replace them on the fly; something like making a string-listener. Any help would be appreciated!
I am no GUI/WinForms program but this would be my personal approach. Add all of these UI elements to a List<T> in the forms constructor. Then in the "replace box checked event handler" you can just iterate over the list applying the same change to all the items. It's by no means a perfect solution but it does mean you only have to statically reference each of the items once. After they're in the list you can operate on all of them very easily.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've just got a stupid question. I have done research but I quite don't understand the explanations given as I'm a beginner in C#.
I have a class called things. The user now ca create a new object in this class by clicking a button. He can give some propertes for the object before, e.g. a description or a name.
This new object has to be created automatically then.
I want a list where all the object names are listed and when the user clicks on one of these, a label should show other properties of the object apart from the name, e.g. the description.
How shall I name these objects the user creates? And how can I make the label show the properties when the user just clicks on the list.
The program has no use really but I want to create it in order to learn how object orientation works.
I hope you understand my question.
Thanks in advance to everybody
Here is my assumption,
You have a Class named "SomeClass", When you click "New" Button, the new object should be created and it should be added to the list.
You can have a List<SomeClass> list = new List<SomeClass>() Which will act as a main list, and you can just use the single object as follows,
ON NEW OBJECT CLICK
SomeClass cls = new SomeClass();
cls.Description ="desc";
list.Add(cls)
Hope this is what you are expecting.