|
You're not creating two lists, you're just changing the values. Also, you are not using strongly typed lists - that isn't causing your problem, but you should change to that.
public class Customer
{
public string CustomerCode { get; set; }
public List<Warehouse> CustomerWarehouses { get; set; }
}
public class Warehouse
{
public string Name { get; set; }
public List<Stock> Stocks { get; set; }
}
public class Stock
{
public string StockCode { get; set; }
public string Description { get; set; }
public int QtyAvailable {get; set;}
}
Note that I changed the name of the "StockCode" list because it is not containing StockCodes, it contains Stock objects. Given that class structure, if you wanted to create two warehouses, A1 and B1, and put one Stock item in each, you need to be careful how you create your lists - you haven't provided any method of initializing them in your classes. You didn't write constructors in these classes, so your List objects start out NULL.
Here's sample code to create two warehouses with one item each...
Create a constructor for the Customer object, to initialize your lists...
public class Customer {
public Customer() {
CustomerWarehouses = new List<Warehouse>();
}
public string CustomerCode { get; set; }
public List<Warehouse> CustomerWarehouses { get; set; }
}
Now, when you create a Customer object, you have a list ready to go, but it contains NO Warehouse objects - you'll have to add one. Can you see where I'm going with this? Think it out in steps and code up those steps - then post all your code if you're still having problems, your original question doesn't include the code we need in order to answer it. SHOW how you're populating these objects.
|
|
|
|
|
Hi, I have created a project in C#.net windows application, The Program.cs file contains two classes named as Program and Option, So my project properties contains two startup object one is windows.Program and other is windows.Options. The code has been run successfully, When i choose startup object as windows.Options then my code has starts to run from windows.Options class and if i choose windows.Program, it starts to run Program class. I need to create a installation package in my project and after installation has been done, my project has to display in start menu. <t>I can create a Installation package and installation also done. Note: The problem is the installation package runs only one startup object. i.e. before create installer, I suppose to choose startup object as "windows.Program" then after create installer and installed successfully then click my installed project, It directly run the windows.Program file. If I suppose to choose "windows.Options" before create installer. then after installation of my project and run means it starts to run windows.Options class. I need to create a single installation package and after installed this package, my project needs to shown in start menu of my system name called "project" and when i click project, it has to show both Program and options. If i choose Program, then it starts to run program part of my project, if I choose Options, then it starts to run Option part of my project. If you know guide me how to create package like this.
|
|
|
|
|
An application can only have a single entry-point. You could use a command-line argument and check that in your apps' Main method, and branch to "Program" or "Option" there.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
you should use command line parameters and read them in Program.cs as below
static void Main()
{
string[] arguments = Environment.GetCommandLineArgs();
if (arguments.Length > 0)
{
foreach (string argument in arguments)
{
if (argument == "something")
{
call options;
}
else
{
call program;
}
}
}
}
next thing you have to create two application shortcuts in setup project and pass respective parameters to them. these are the same parameters which will read by program.cs.
based on this you can toggle start up object on you application.
Hope this helps..
pls reply if you need something else
|
|
|
|
|
how are charts resized in windows form the same way charts in excel. I think charts in excel convert to an image and then resized.
|
|
|
|
|
Member 9811332 wrote: I think charts in excel convert to an image and then resized. Why would you think that? Resizing is merely repainting the frame and its contents according to the new position and dimensions set by the user.
Use the best guess
|
|
|
|
|
i have some problem in handling mdi windows form
in my application i want that when open a child form after the clicking of menuitem in mdiparent form, then after that mdiparent form will be disabled and when i will close the child form the mdiparent form will be enabled again.
during the disability uer can not close the parent form , user must hav to close the child form firt thn after user may can close the parent form.
can any help me in it how to do it in c#...........
|
|
|
|
|
Arun kumar Gautam wrote: can any help me in it how to do it in c#. You just need to keep some state flags to tell you whether the form can be closed or not.
Use the best guess
|
|
|
|
|
It is very hard to understand the issue that you are facing using mdi windows form. Can you please rewrite your problem using proper language without any spelling errors?
|
|
|
|
|
The behaviour you describe is default for a modal dialog. A MDI-document is exactly that, a document-interface - not a dialog.
Use a normal form, call the ShowDialog method.
Done.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'm testing the software. Database functions are connected using BackgroundWorker or not load any data into the control, only assign backgroundimage but at load user control on the user control the control it still blinks for 5 seconds. who have there a way to fix that for load control in the user control that does not flicker? Thank you everyone
|
|
|
|
|
Lương Tuấn Anh wrote: who have there a way to fix that for load control in the user control that does not flicker? Pause the painting[^] while updating the property and set your form to DoubleBuffered. You can post the code here if you want specific tips.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i will set property for form is DoubleBuffered = true . but it did not improve much. >.<
|
|
|
|
|
DoubleBuffering the form will speed up drawing "a bit". Disabling drawing as suggested will improve it "a bit" too. Without your code, I can only give these options. If you only need to assign the image to a control, then there would be not much of a "flickering", albeit the screen will show the update.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have one form and one panel. my Panel set background image are .png. form set DoubleBuffered = true. One user control have more than 10 controls (combobox, textbox...) when User control add to this panel, it flicker
< ====== My Code> http://www.mediafire.com/?1mgh5qjcly1auq2[^]
UC 1 : have DoubleBuffered = true.
But I don't want form flickered when load. I want form load the same when form don't set background image.
|
|
|
|
|
Lương Tuấn Anh wrote: But I don't want form flickered when load.
Then read the link provided to stop it drawing while running the InitializeComponents-method. How long does it take to show that form? Contains many controls?
--edit;
The idea would be for you to post the relevant code, surrounded with pre-tags, not a binary package.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i don't knows. you can said more details or help me code in this project. Thank
|
|
|
|
|
Lương Tuấn Anh wrote: you can said more details or help me code in this project. That's what I'm trying. Let's try it another way; copy the method below (comes from here[^])
public static class SuspendUpdate
{
private const int WM_SETREDRAW = 0x000B;
public static void Suspend(Control control)
{
Message msgSuspendUpdate = Message.Create(control.Handle, WM_SETREDRAW, IntPtr.Zero,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgSuspendUpdate);
}
public static void Resume(Control control)
{
IntPtr wparam = new IntPtr(1);
Message msgResumeUpdate = Message.Create(control.Handle, WM_SETREDRAW, wparam,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgResumeUpdate);
control.Invalidate();
}
}
Call it in the InitializeComponents , or whereever you put the image in the control.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
can you give me one example for it .. i'm newbie ... thank you very much
|
|
|
|
|
Ehr, no; read the article, it contains the example.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
ok , thank you . i will ask you if i dont know thank you verry much. Do you have Yahoo or mail ?
|
|
|
|
|
Lương Tuấn Anh wrote: i will ask you if i dont know Please do so - wrote the example in a few spare moments, based on a new project;
using System;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
SuspendUpdate.Suspend(this);
InitializeComponent();
SuspendUpdate.Resume(this);
}
public void button1_Click(object sender, EventArgs e)
{
SuspendUpdate.Suspend(this.pictureBox1);
this.pictureBox1.Image =
SuspendUpdate.Resume(this.pictureBox1);
}
}
public static class SuspendUpdate
{
const int WM_SETREDRAW = 0x000B;
public static void Suspend(Control control)
{
Message msgSuspendUpdate = Message.Create(
control.Handle, WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgSuspendUpdate);
}
public static void Resume(Control control)
{
IntPtr wparam = new IntPtr(1);
Message msgResumeUpdate = Message.Create(
control.Handle, WM_SETREDRAW, wparam, IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgResumeUpdate);
control.Invalidate();
}
}
} Here we add in some help-routines in a new class; they should be in a separate file. Before updating something, call "Suspend" to stop the drawing temporarily and "Resume" to active it again. It'll speed up things on the UI-thread if it doesn't have to paint every change. I've also surrounded the "InitializeComponents" routine with those calls, to speed up the load-time. Again, it helps "a bit", it's not a miracle-worker. If your image is very large (>5 Mb), then it might be wiser to change the image.Lương Tuấn Anh wrote: Do you have Yahoo or mail ? I'm every day available on CodeProject; whenever I open GMail, I also open CodeProjects' forum. I'd also get an email if you reply to one of my messages
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
i will set SuspendUpdate for UC and panel but controls add in UC disappeared at load. when mouse move to controls, it will show. Do you see for me will set SuspendUpdate ok?
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 testForm
{
public partial class Form1 : Form
{
public Form1()
{
SuspendUpdate.Suspend(this);
InitializeComponent();
loadUC1();
SuspendUpdate.Resume(this);
}
public void loadUC1()
{
panel1.Controls.Clear();
UserControl1 test = new UserControl1();
SuspendUpdate.Suspend(this.panel1);
panel1.Controls.Add(test);
SuspendUpdate.Resume(this.panel1);
}
public void loadUC2()
{
panel1.Controls.Clear();
UserControl2 test2 = new UserControl2();
SuspendUpdate.Suspend(test2);
panel1.Controls.Add(test2);
SuspendUpdate.Resume(test2);
}
private void button1_Click(object sender, EventArgs e)
{
loadUC1();
}
private void button2_Click(object sender, EventArgs e)
{
loadUC2();
}
}
public static class SuspendUpdate
{
private const int WM_SETREDRAW = 0x000B;
public static void Suspend(Control control)
{
Message msgSuspendUpdate = Message.Create(control.Handle, WM_SETREDRAW, IntPtr.Zero,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgSuspendUpdate);
}
public static void Resume(Control control)
{
IntPtr wparam = new IntPtr(1);
Message msgResumeUpdate = Message.Create(control.Handle, WM_SETREDRAW, wparam,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgResumeUpdate);
control.Invalidate();
}
}
}
and code in UC
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace testForm
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
SuspendUpdate.Suspend(this);
InitializeComponent();
this.DoubleBuffered = true;
SuspendUpdate.Resume(this);
}
}
}
all with the same result.
|
|
|
|
|
Only one control can be suspended at a time; remove the suspend-methods in the UserControls and it should work
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|