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.
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 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 7 years ago.
Improve this question
when I put a breakpoints on my textbox it shows textbox.length = "" even if there are characters in the textbox
There is no Length property present in TextBox Class.
Probably you mean to Check the Length on Textbox Text property which is of string type.
textbox.Text.Length
More info about the code would be nice. Is your Textbox really enabled? No transparent layer in front of it? You used the mySQL-Tag. Does that mean you use some kind of binding in textbox? Possibly you can't change the content of your textbox, because the database-binding / connection is read-only?
Is there really some textbox.length property?? Are you sure you are referring to the right property? Try this:
Convert.ToString(textBox1.TextLength)
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
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 8 years ago.
Improve this question
I need to know where I can access the basic code, for example a "NumericUpDown" Element.
What I want to do:
Add Code to my NumericUpDown Element, for example:
Set the "Maximum"-Value to a variable embedded inside my Formclass code.
The Reason why I cant to it right now:
I just can access the NumericUpDown Element just in the Design View right now. There I can Input a value, but can't set it to the amount stored in a variable.
I just know, that If I double click the field, I get a "ValueChanged" Method into my code. But what I need to know: How can I access the "basic" Code of the NumericUpDown Element, where I could set the "Maximum"-Property?
I'm relatively new to programming. And I'm quite overwhelmed with a lot of things... So I COULD google for the problem but it would just take me way to much time.
Since I guess it's an easy answer for you guys, I post it here.
Thanks a lot!
You can access the Control's objects attributes by it's name.
For example:
NumericUpDown1 <- It's the name of your Control
In your C# code you can access all of it's attribtes and methods by puttin a period after it's name:
NumericUpDown1.Maximun = 100;
NumericUpDown1.Width = 250;
NumericUpDown1.Height = 10;
etc. You can serach it by "Control Properties" in google. Luck and effort! :P Remember to try and search a bit before asking. Don't wait for others to make your job. Luck! ^.^
You can access source code of components, but it won't help you. every component has interface and you can use it's interface to interact with it. Also you can override some methods of component to change their behavior.
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.