|
Why would you want to do something that cumbersome?
Perhap you need to explain in more detail exactly what you are trying to do?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi, thanks a million for your reply.
Sometimes there are many data that i want to share between two forms. So it is easier to use from properties.settings.default (for me). that works very good and i can save and retrieve my data in the most simple way. So sometimes i prefer to use from them. setting files with user scope, are accessible all over the program directly. So i am doubtful about their security hazards. That is why i have asked the question.
|
|
|
|
|
Do you have any idea how inefficient that is?
Every time you want to access items in memory, you will be going via a hard drive!
You do realise that Properties.Settings is backed by an XML file, so every time you write to them there is a heck of a lot of "read the file, copy it up to the parameter we want, write the new value instead, copy the rest of the file" going on behind the scenes? And reading it means "read the file, scan it for the parameter we want, copy the value" each time?
And that if you want to use the same class in two places, they will clash on the settings file because it only knows about one parameter?
Start doing it a lot - and you will, because "it works" - and you will slug the heck out of your computer. Learn to do it properly, and it not only works better, but is considerably more maintainable.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi,
I do not know how should i thanks from you for your help and guide. Can you give me a link of an article that how should i save and retrive my data in the minimum time and what the best way is? .thanks a million.
|
|
|
|
|
Well, the way I'd do it is to create a separate class to act as a "data transfer" class and fill an instance of that in the property getter.
That way, all the related data is together, and in its correct data format ready to be used.
You presumably know how to create a class?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi,
As i have gotten your point, Yes i know how to create a class, and how to use from get and set. But my means is about save and retrieve data and not about sharing them. But if you means is a different thing, no unfortunately i have no idea about that and if so, do me a favour and guide me through it, please.
Thaaaaaaaank you again .
modified 25-Sep-18 16:35pm.
|
|
|
|
|
i hope the user will input number of rows and number of columns in 2 textboxs, then click the Generate button and a grid of PictureBoxes will be generated on panel.
Initially the grid will be empty.
The Grid is composed of PictureBoxes which are generated dynamically.
|
|
|
|
|
All you need is to decide a couple of things, given dX, dY as the usable width and height of the panel inside any edge margins, and R, C are the number of rows and columns.
First pick how big a margin M you want around each panel (we'll assume that M is the same top and side)
width of each image = (dY - (C - 1) * M) / C
height of each image = (dY - (R -1 ) * M) / R Now all you need to do is nest two loops, and create your PictureBoxes, setting the Size of each to (width, height) and the Location to (columnNumber * (width + M), rowNumber * (height + M)) (both offset by the margin round the edges of the panel, obviously)
Then add each PictureBox to the Panel.Controls collection.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
thank you i find a way to create it !
private void btnGenerate_Click(object sender, EventArgs e)
{
panel3.Controls.Clear();
int rows = Convert.ToInt32(txtRows.Text);
int columns = Convert.ToInt32(txtColumns.Text);
PictureBox[,] map = new PictureBox[rows,columns];
for (int j = 0; j < columns; j++)
{
for (int i = 0; i < rows; i++)
{
System.Threading.Thread.Sleep(50);
map[i, j] = new PictureBox();
map[i, j].Width = 45;
map[i, j].Height = 45;
map[i, j].BackColor = Color.NavajoWhite;
if (i == 0 && j == 0)
{
map[i, j].Location = new Point(100, 100);
}
map[i, j].Location = new Point(45 * i + 100, 45 * j + 100);
map[i, j].BorderStyle = BorderStyle.Fixed3D;
panel3.Controls.Add(map[i, j]);
}
}
}
|
|
|
|
|
what is the best way to process image i have a scenario i have floor map of parking and first i want to allocate as an available slot in the system once it is available slot i need to assign it to one of the staff once assign i want to show this area as red and available slot as green on this floor image. kindly assist me that what is the best way to implement this in C# ASP.NET.
Thanks in advance.
|
|
|
|
|
What have you tried?
Where are you stuck?
What help do you need?
This is not a good question - we cannot work out from that little what you are trying to do.
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. And you haven't told us much at all ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If I were doing this, given several assumptions about what you are asking, I'd probably do it using Scalable Vector Graphics (SVG).
This space for rent
|
|
|
|
|
Hi all!
New to the forum
I have a made a application that stores it's settings with the following code:
Properties.Settings.Default.Username= TxtUsername.Text;
Properties.Settings.Default.Password = TxtPassword.Text;
Properties.Settings.Default.Tel = TxtTel.Text;
Properties.Settings.Default.EMail = TxtEMail.Text;
Properties.Settings.Default.Save();
Loading the settings works just fine, but with one exception.
If I change the code in any way, the settings changes to "\r\n\t\t\t\t".
I can image it is because the application has changed or something like that.
But is there any way to make it so it changes to "" instead?
Want to make a function to check if the settings have been set by checking each of them if they are null. Dosent work that well if they either are null or contain "\r\n\t\t\t\t".
Note that I am using SharpDevelop, I am at work and I can't get VS Studio here, unfortunatly.
|
|
|
|
|
I am a 100% online student trying to learn C#. My instructor has not been of help, so I am looking for help elsewhere.
My homework is to create a program that will convert measurements:
"
In the English measurement system, 1 yard equals 3 feet and 1 foot equals 12 inches. Use this information to create an application that lets the user convert distances to and from inches, feet, and yards. Use list boxes for the user to select units being converted from and another list box for the user to select units being converted from.
Write your code in the following order
Program must check for correct input into the textbox. Hint: use TryParse.
Check that user has selected a from unit. If not, let user know no unit has been selected.
Check that user has selected a to unit. If user selects the same unit for both from and to, let them know that they need to select a different unit. "
I believe I have my TryParse correct. It will make sure a measurement has been entered, a from distance has been selected and a to distance has been selected. After that, I am not sure where to proceed. I don't know how to grab what is selected in the from groupbox to the to groupbox and then convert. Any help would be appreciated. Thanks!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Distance_Converter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void convertButton_Click(object sender, EventArgs e)
{
double distanceInput;
double inches;
double feet;
double yards;
string measurementFrom;
if (double.TryParse(distanceTextBox.Text, out distanceInput));
{
if (fromListBox.SelectedIndex != -1)
{
if (toListBox.SelectedItem = != -1)
{
}
}
}
}
}
}
Image of UI: Capture — imgbb.com[^]
|
|
|
|
|
Your tryparse is correct but you are not doing the job asked of you, you test the input but do nothing if it is incorrect.
Do each test in isolation rather than nesting them.
Test that the input will parse as a double (add a message to a string if it fails)
Test that the distance input is not zero
Test that a from unit has been selected (add a message to a string if it fails)
test that a to unit has been selected
test that the selected unit type are not the same (have the same selectindex)
Tell the user of any errors in the testing phase
Use the selectedindex to get the unit type for each listbox from the underlying collection
You now have the distance, the from type and the to type. The conversion is a simple math operation.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm relearning C#, and due to my lack of funds, am using a computer that's over 5 years old and cannot even create console apps except using an online compiler. For some reason, Visual Studio will not create console apps. But that's beside the point.
I was given a file, and the task to sort out which items go on which shelf. It uses a lot of classes and arrays, my weak point in C#. So I thought I'd post here to see if someone could help me out with this.
The program itself is:
* At ACME warehouse the warehouse manager has observed orders taking a long time to pick and
* believes that moving more popular items to easier to access locations may help.
*
* - Workers pick an order by placing items on a pallet at the dock door.
* - Products are stored (inefficiently) in a single aisle with multiple shelves.
* - As the shelf number increases, it is located further down the aisle and
* further away from the dock door.
* - On average it takes 5*X seconds for a warehouse worker to retrieve an item
* from shelf X and place it on the pallet.
* - A warehouse worker can only carry a single item at a time.
* - A shelf can only hold one type of item.
*
* Which items should be on which shelves to optimize picking speed based on
* yesterday's orders?
*
*
* Example output
*
* Shelf 1: Item 12
* Shelf 2: Item 11
* Shelf 3: Item 10
* Shelf 4: Item 09
* Shelf 5: Item 08
* Shelf 6: Item 07
* Shelf 7: Item 06
* Shelf 8: Item 05
* Shelf 9: Item 04
* Shelf 10: Item 03
* Shelf 11: Item 02
* Shelf 12: Item 01
*
*/
OrderRepository orderRepo = new OrderRepository();
// write your code here
Console.WriteLine("Order " + Order[1].OrderLine[1]);
The functions are:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WarehouseOptimization
{
public class Order
{
public OrderLine[] orderLines;
public int id;
public string customerName;
}
public class OrderLine
{
public int quantity;
public string itemName;
}
public class OrderRepository
{
public Order[] GetYesterdaysOrders()
{
Order[] orders = new Order[] {
new Order{
id = 1,
orderLines = new OrderLine[] {
new OrderLine{ itemName = "Item 01", quantity = 1},
new OrderLine{ itemName = "Item 02", quantity = 3},
new OrderLine{ itemName = "Item 03", quantity = 25},
new OrderLine{ itemName = "Item 04", quantity = 12},
},
},
new Order{
id = 2,
orderLines = new OrderLine[] {
new OrderLine{ itemName = "Item 01", quantity = 1},
new OrderLine{ itemName = "Item 08", quantity = 42},
new OrderLine{ itemName = "Item 09", quantity = 13},
new OrderLine{ itemName = "Item 12", quantity = 37},
},
},
new Order{
id = 3,
orderLines = new OrderLine[] {
new OrderLine{ itemName = "Item 12", quantity = 16},
},
},
new Order{
id = 4,
orderLines = new OrderLine[] {
new OrderLine{ itemName = "Item 10", quantity = 11},
new OrderLine{ itemName = "Item 11", quantity = 10},
},
},
new Order{
id = 5,
orderLines = new OrderLine[] {
new OrderLine{ itemName = "Item 06", quantity = 7},
new OrderLine{ itemName = "Item 07", quantity = 2},
new OrderLine{ itemName = "Item 12", quantity = 14},
},
},
new Order{
id = 6,
orderLines = new OrderLine[] {
new OrderLine{ itemName = "Item 05", quantity = 17},
},
},
new Order{
id = 7,
orderLines = new OrderLine[] {
new OrderLine{ itemName = "Item 03", quantity = 5},
new OrderLine{ itemName = "Item 07", quantity = 2},
},
},
new Order{
id = 8,
orderLines = new OrderLine[] {
new OrderLine{ itemName = "Item 02", quantity = 13},
new OrderLine{ itemName = "Item 07", quantity = 7},
new OrderLine{ itemName = "Item 09", quantity = 2},
},
},
new Order{
id = 9,
orderLines = new OrderLine[] {
new OrderLine{ itemName = "Item 01", quantity = 4},
new OrderLine{ itemName = "Item 06", quantity = 17},
new OrderLine{ itemName = "Item 07", quantity = 3},
},
},
new Order{
id = 10,
orderLines = new OrderLine[] {
new OrderLine{ itemName = "Item 11", quantity = 12},
new OrderLine{ itemName = "Item 12", quantity = 1},
},
},
};
return orders;
}
}
}
I used Excel to figure out the proper order for everything:
Quote: number item
68 12
42 8
30 3
24 6
22 11
17 5
16 2
15 9
14 7
12 4
11 10
6 1
With this, item 12 is most ordered, so it should go on shelf 1, and so on.
My question is how do I sort all this stuff program-wise?
Thanks in advance for your help.
|
|
|
|
|
So you have a collection of Order objects (class) each of which has a collection of OrderLine objects (class). You need to work with the total collection of OrderLine independent of the containing Order.
I would create another collection of Orderline and loop through the Order collection and add each OrderLine to the new collection
static void Main(string[] args)
{
OrderRepository oRepository = new OrderRepository();
List<Order> lOrders = oRepository.GetYesterdaysOrders().ToList();
List<OrderLine> oLines = new List<OrderLine>();
foreach (Order Item in lOrders)
{
oLines.AddRange(Item.orderLines);
}
Console.WriteLine(string.Format("Order Lines {0}", oLines.Count));
foreach (OrderLine oLine in oLines.OrderByDescending(x => x.quantity))
{
Console.WriteLine(string.Format("Item {0} Qty {1}", oLine.itemName,oLine.quantity));
}
Console.ReadLine();
}
The above code will give you an idea how to manipulate the collections - you need to research how to aggregate the collection to meet your needs.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
to do a project , SOAP webservice from client to server for sending work order and based on the request generate the response
|
|
|
|
|
And? Apart from that vague statement, do you actually have a question?
This space for rent
|
|
|
|
|
yes I don't know how to send variables and manage them on server side and send the result on client side
|
|
|
|
|
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
Try it yourself, you may find it is not as difficult as you think!
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
well I know that if I make a web service and a console application and connect them by reference it automatically generate and send requests as soap but I don't know how to define variables send it to the server and do process on them on server side and send the result to the client side
|
|
|
|
|
Hi,
I am looking to store my data that is not in a fixed format in an array or list but as array is of fixed size so cant use that, list provides flexibility but it doesnt comes with multi dimensions option like array does..
I had a data like:
"Acids", "A1", "A2", "A3" - this could grow to ph4 till ph 10 depends
"Sulphur" "S1", "S2", - this could grow to ph4 till ph 0 depends
"Carbon" "c1", C2" can grow depends
also after storing it in the list i also need to retrieve in a way that in a loop i should get first Acids then all its sub components that is A1, A2, A3, once done then move to Sulphur and get its corresponding components.
Please can anyone suggest anything on how to best deal with this.
|
|
|
|
|
How about a Dictionary<string, List<string>> ?
Dictionary with Single Key and Multiple Values Example in C#. See https://repl.it/CY3S/1 to run example code online. · GitHub[^]
Eg:
var data = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase)
{
["Acids"] = new List<string> { "A1", "A2", "A3" },
["Sulphur"] = new List<string> { "S1", "S2" },
["Carbon"] = new List<string> { "C1", "C2" },
};
if (!data.TryGetValue("Acids", out var acids)) acids = data["Acids"] = new List<string>();
acids.Add("A4");
if (data.TryGetValue("Sulphur", out var sulphur)) sulphur.Remove("S1");
foreach (KeyValuePair<string, List<string>> pair in data)
{
Console.WriteLine(pair.Key);
foreach (string value in pair.Value)
{
Console.WriteLine(value);
}
Console.WriteLine();
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
A list of lists is probably as close as you can get. Though it seems to me a lot less flexible, another option to consider is a dictionary where the key is an object or struct that stores the array subscripts. Since I suspect such a dictionary could get really ugly really fast, I would be inclined to use a list of lists.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
|
|
|
|
|