C# win forms .net core, user control, array on a dialog.
-
I made a user control to represent cardboard boxes, probably a bad idea. The idea is to be able to add a box, like if you have 3 boxes. I was thinking like in Angular, you can make a control array, so it was just natural for me to make a user control. I placed one on my dialog, and I'm just drawing a blank on how to handle this on the dialog. Haven't tried anything yet, but did look around and all the examples were for check boxes. I suppose if I can't make it work, I can re-purpose it to fill a list box, or to fill the box array in my model.
If it ain't broke don't fix it Discover my world at jkirkerx.com
-
I made a user control to represent cardboard boxes, probably a bad idea. The idea is to be able to add a box, like if you have 3 boxes. I was thinking like in Angular, you can make a control array, so it was just natural for me to make a user control. I placed one on my dialog, and I'm just drawing a blank on how to handle this on the dialog. Haven't tried anything yet, but did look around and all the examples were for check boxes. I suppose if I can't make it work, I can re-purpose it to fill a list box, or to fill the box array in my model.
If it ain't broke don't fix it Discover my world at jkirkerx.com
What do you do with the "boxes"? In Windows Forms, WPF and UWP there are "wrapping" controls with a .Children collection, that will space out anything you add to them: user controls; buttons; shapes; etc. No "positioning" required. You attach click / touch / mouse / wheel handlers to these "children" (that you add) to get them to do what you want. (Or you intercept events at the form level if you can determine the target: fewer hooks) You iterate over the .Children (or a shadow observable collection) if you want to do some group action.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
-
I made a user control to represent cardboard boxes, probably a bad idea. The idea is to be able to add a box, like if you have 3 boxes. I was thinking like in Angular, you can make a control array, so it was just natural for me to make a user control. I placed one on my dialog, and I'm just drawing a blank on how to handle this on the dialog. Haven't tried anything yet, but did look around and all the examples were for check boxes. I suppose if I can't make it work, I can re-purpose it to fill a list box, or to fill the box array in my model.
If it ain't broke don't fix it Discover my world at jkirkerx.com
To assist you, we need to know more about what the "boxes" represent, how they are used, does the user interacts with them at run-time, etc. Do the "boxes": contain other Controls: if so, what are they ?
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
-
To assist you, we need to know more about what the "boxes" represent, how they are used, does the user interacts with them at run-time, etc. Do the "boxes": contain other Controls: if so, what are they ?
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
Thank You, yes, it is a real-time software that showing data (querying) whilst data are recorded, and user(s) can querying anytime they need. Values will be shown in textBoxes and chart controls. my database structure only contains double-precision, string, and int Fields. If My info is not enough tell me and i will add anything needed. Thank you again.
-
Thank You, yes, it is a real-time software that showing data (querying) whilst data are recorded, and user(s) can querying anytime they need. Values will be shown in textBoxes and chart controls. my database structure only contains double-precision, string, and int Fields. If My info is not enough tell me and i will add anything needed. Thank you again.
No, what Bill is asking for is simpler: UserControl is a special class that allows you teh developer to create a displayable object that shows information to the user and accepts user input - exactly as a TextBox does. We need to know if the user interacts directly with them (and how if so), how they are used in your app - if you have created the correct object, in fact. If they are always "internal" to yoru app and are never visible to the user then a UserControl is the wrong choice - a simple
class
is better as all displayable controls bring a lot of necessary "baggage" with them that a class does not. If you are trying to show items on a form, then a UserControl is the way to go, but we need to know what you are trying to do with them from a user point of view before we can help you - remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with."I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
No, what Bill is asking for is simpler: UserControl is a special class that allows you teh developer to create a displayable object that shows information to the user and accepts user input - exactly as a TextBox does. We need to know if the user interacts directly with them (and how if so), how they are used in your app - if you have created the correct object, in fact. If they are always "internal" to yoru app and are never visible to the user then a UserControl is the wrong choice - a simple
class
is better as all displayable controls bring a lot of necessary "baggage" with them that a class does not. If you are trying to show items on a form, then a UserControl is the way to go, but we need to know what you are trying to do with them from a user point of view before we can help you - remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with."I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
The boxes are literary, well represent card board boxes for shipping. In the user control, you select the item, enter unit cost, how many units, and ship label price. Every shipment has at least one box. You can add boxes, say if your shipment has 4 boxes to ship. So if you have 60 units to ship, and 15 units go in each box, you have 4 boxes.
If it ain't broke don't fix it Discover my world at jkirkerx.com
-
The boxes are literary, well represent card board boxes for shipping. In the user control, you select the item, enter unit cost, how many units, and ship label price. Every shipment has at least one box. You can add boxes, say if your shipment has 4 boxes to ship. So if you have 60 units to ship, and 15 units go in each box, you have 4 boxes.
If it ain't broke don't fix it Discover my world at jkirkerx.com
So are they pictures of boxes? Do I click on them? Or are they a list of contents plus "add / remove" buttons? Seriously, we only get exactly what you type to work with here!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
So are they pictures of boxes? Do I click on them? Or are they a list of contents plus "add / remove" buttons? Seriously, we only get exactly what you type to work with here!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
My Bad It's a rectangle, with 1 combo at the top, then 3 textboxes underneath. No add / remove buttons, they are at the top of container, outside the user control. I tried to draw a picture with text, didn't work out.
If it ain't broke don't fix it Discover my world at jkirkerx.com
-
I made a user control to represent cardboard boxes, probably a bad idea. The idea is to be able to add a box, like if you have 3 boxes. I was thinking like in Angular, you can make a control array, so it was just natural for me to make a user control. I placed one on my dialog, and I'm just drawing a blank on how to handle this on the dialog. Haven't tried anything yet, but did look around and all the examples were for check boxes. I suppose if I can't make it work, I can re-purpose it to fill a list box, or to fill the box array in my model.
If it ain't broke don't fix it Discover my world at jkirkerx.com
So I deleted the control off the dialog box, and decided to create the control in code. This is where I got confused. I made a panel, set the sizes up static, and wrote some code, where I click on "ADD", and add the user control to the panel. I did figure out the direct injection part, injecting my inventory repository, and when adding the control the Item list populates. It's a start at least. Just need to calculate the next box location. I can relate to this, and will test it out and see how it goes before I abandon the idea. Maybe I should be using that Flow Panel control.
private void Btn_Add_Click(object sender, EventArgs e)
{
var ucCount = panelItems.Controls.Count;
var ucLocation = new Point(0, 0);var shipmentControl = new AmazonFBAShipmentControl(inventoryRepository); shipmentControl.Location = ucLocation; panelItems.Controls.Add(shipmentControl);
}
If it ain't broke don't fix it Discover my world at jkirkerx.com
-
My Bad It's a rectangle, with 1 combo at the top, then 3 textboxes underneath. No add / remove buttons, they are at the top of container, outside the user control. I tried to draw a picture with text, didn't work out.
If it ain't broke don't fix it Discover my world at jkirkerx.com
Right - so it has to be a UserControl, and you need to have an "expanding" collection control to put them on. I'd probably start with a FlowLayoutPanel - but it depends on how you want to arrange them. Every time you click the button, it adds another item to it and flows them around to fit:
private void button1\_Click(object sender, EventArgs e) { Button b = new Button(); b.Text = $"Hello: {++buttonsCount}"; b.Click += MyAddedButton\_Click; myFlowLayoutPanel.Controls.Add(b); } private int buttonsCount = 0; private void MyAddedButton\_Click(object sender, EventArgs e) { Console.WriteLine((sender as Button)?.Text); }
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
Right - so it has to be a UserControl, and you need to have an "expanding" collection control to put them on. I'd probably start with a FlowLayoutPanel - but it depends on how you want to arrange them. Every time you click the button, it adds another item to it and flows them around to fit:
private void button1\_Click(object sender, EventArgs e) { Button b = new Button(); b.Text = $"Hello: {++buttonsCount}"; b.Click += MyAddedButton\_Click; myFlowLayoutPanel.Controls.Add(b); } private int buttonsCount = 0; private void MyAddedButton\_Click(object sender, EventArgs e) { Console.WriteLine((sender as Button)?.Text); }
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Good call. I changed the panel to the flow layout panel, went top to bottom. This is really cool! This panel automatically positions my user control perfect and makes a scroll bar when needed. I'm in the process of wiring it all up now, so far so good. No different than passing data from a form to a dialog. You can't see me, but I have a huge smile on my face. :) And I know I choose the right path. I'm very happy with .Net Core Win Forms using direct injection, so far it's working great for me. I love using the app I made with this technology. Thanks Griff!
If it ain't broke don't fix it Discover my world at jkirkerx.com
-
Good call. I changed the panel to the flow layout panel, went top to bottom. This is really cool! This panel automatically positions my user control perfect and makes a scroll bar when needed. I'm in the process of wiring it all up now, so far so good. No different than passing data from a form to a dialog. You can't see me, but I have a huge smile on my face. :) And I know I choose the right path. I'm very happy with .Net Core Win Forms using direct injection, so far it's working great for me. I love using the app I made with this technology. Thanks Griff!
If it ain't broke don't fix it Discover my world at jkirkerx.com
You're welcome!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!