|
Hi,
welcome to CodeProject.
Sueberl wrote: "Controls" does not work
that is not informative. If it won't compile, give us the error message; if it compiles but won't run, give us the symptoms.
What you are trying to do seems very strange to me; I've never felt the urge to copy controls from one location to another; I would rather design a UserControl and then instantiate it, which isn't exactly the same, as you are copying the controls with their entire state (such as the content of TextBoxes or ListBoxes, the checks of CheckBoxes, etc). Which I can't imagine one would want.
Anyway, Tab.Create_Tabs(Controls); looks like a correct statement to me.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Wow THX for the quick answer
imagine u have the Controls to do something on the base Form (without an Tab) if u press a button u have on the first Tab the Controls and for example the results of the product (what u control) on the other one. Thats my motivation.
ahm the error below: ( I translated it from german)
Error 1 For the non-static field, method, or property "Tab.Create_Tabs(System.Windows.Forms.Control.ControlCollection)" is an object reference is required
Hope this helps.
Controls in my case is where all Controls from the Form are in.
|
|
|
|
|
Making no assumptions about your variable naming,
Where is your Create_Tabs method declared?
What is Tab ?
|
|
|
|
|
Hi,
1.
when you call X.Y() either X is a class name and Y() is a static method inside X, or X is an instance of some class holding a non-static method Y().
I assume Tab is the name of the class holding the code you've shown, that makes it an invalid mix of the two valid cases I just mentioned.
2.
I would start with a form that holds a TabControl with one tab holding all Controls of interest. Then add a second tab as appropriate; nothing needs copied/moved as I understand it.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
modified on Tuesday, February 16, 2010 9:25 PM
|
|
|
|
|
Thanks Luc and hammerstein for your help!
Really nice from u two
I forgot to create the new class, so i forgot the following line
Now it works fine thx.
Class_Tab Tab = new Class_Tab();
hmm i feel kind of ashamed ....
Thanks again...
|
|
|
|
|
No problem.
I see your coding style isn't quite what it should be. For instance, you should not include "class" in a class name; and conventionally local vaiables are set in lower-case; etc.
As you are new to all this, I suggest you buy and study a book; it will introduce you to a lot of information, in a structured way and intelligent order, and it will let you pick up a lot of good habits right away.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi,
I'm new to the C language, but I am taking a course in it. My class has a project that I am having some trouble with. If anyone can give me some code to reference, a source code, or just point me in the right direction, it would be greatly appreciated.
Here is the assignment:
Create a simulation of 100 squares, each 16x16 pixels wide. Each square is initially white in color. Each square should be given a random position on screen, and a random initial velocity of between 0 and 5 pixels per clock tick in both x and y axes (i.e., x and y velocity can be different from each other). Square positions are updated every clock tick.
When squares collide, they change color to red, and remain red until they finish colliding. When a square no longer is intersecting another square, it reverts back to white.
A quadtree data structure of at least depth 4 must be part of the implementation of collision detection. Square position updates must result in updates to the quadtree, rather than a complete recomputation of the quadtree. It is unacceptable to regenerate the quadtree in each clock tick.
When a square hits the edge of the window, it should "bounce", and thereby stay in the visible part of the playfield.
Use of the GOTO statement outside of case statement blocks is forbidden.
_______
I reiterate, I know very little about C, so I even need help drawing the squares. Anything you can do to help, I really appreciate it. I will (obviously) credit whomever sends me reference/source code.
Thanks in advance
-Magy
|
|
|
|
|
Hi,
welcome to CodeProject. We gladly answer specific questions, we do not do homework in general. And it pays to show you made some effort yourself.
For starters, is it C or C# you use (or even C++)? for C and C++, we have other forums.
If you don't know how to paint on a screen, you should refer to your course, or to the Microsoft documentation, or just Google. The answer depends on the language you use.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
I am using C#. I'm not looking for someone to do the project for me. I'm new to the language, and I just need some help getting started on this project. I have used my available resources (including Google), but the tutorials I have found are extremely vague, or irrelevant to my needs - which is why I came here.
|
|
|
|
|
You mentioned a course and a class; those could be your primary sources of information.
You might learn some relevant stuff by reading some articles. In the list of my articles, you might look into the ones on GraphicsPath, Animation, Sokoban.
Within the realm of MSDN you should read about the Graphics class, e.g. DrawRectangle and/or FillRectangle.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
You can draw "raw graphics" (coloured squares, lines, etc) in the paint event of a form/control (e.Graphics.whatever )
Your question is awfully vague though..
|
|
|
|
|
what I'm going for here is something like this. i have a program i created I'm going to copy the .EXE
and a file to a CD, I'm going to give this CD to a user i want the program to auto run, meaning when the
user inserts the CD the program is just going to auto launch. Now i know how to auto launch the .EXE
with a .INF file but the problem i am having is this. In order for the program to run correctly it needs
to grab the file path that's on the CD with the program. My question is how can i associate the file with
the .EXE? I just need the path to the file for my program to run correctly. Before i was using a open
file dialog to allow the user to grab the path for me but now like i said i want it to auto run. I could
hard code the path to the file but there no guarantee that the end user CD drive will be the same as what
i code. Maybe using a XML file? or doing something with Environment class?? hopefully i explained well
enough if not please fill free to ask and i will try to explain better. thank you
|
|
|
|
|
have a look at Application.ExecutablePath
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
so i wrote the code below and it worked it automatically moved a file from my D: drive to my C: drive but when i try to run it from a CD, it erros out with the following
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.String.Substring(Int32 startIndex, Int32 length)
at CustomerDecrypt.Form1.OutputFileNameDe()
at CustomerDecrypt.Form1.AutoRun()
at CustomerDecrypt.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
private string path = Path.GetDirectoryName(Application.ExecutablePath);
private void AutoRun()
{
txtBoxDecrypt.Text = path;
string newPath = path.Substring(0, 3);
newPath += "bb.zip.dpa";
MessageBox.Show(newPath);
OutputFileNameDe();
CreateDirectory();
string copyFile = @"C:\!@#$%Encrypted\" + txtBoxDecryptOutputFile.Text + ".dpa";
txtBoxDecrypt.Text = copyFile;
File.Copy(newPath, copyFile, true);
System.IO.FileInfo fileInfo = new System.IO.FileInfo(copyFile);
fileInfo.IsReadOnly = false;
}
|
|
|
|
|
What does OutputFileNameDe( ) do ? That is where the stacktrace is pointing.
|
|
|
|
|
i got it figure out txtboxdecrypt was null, it only held my cd drive letter. thanks to everyone for the help as always.
|
|
|
|
|
Please I want to start automatically my service when I use installutil without start it manually.I set start property in automatic in visual studio but in service explorer I must start service once manually.But after this it's start itself.
Thank you.
|
|
|
|
|
If you set start type to automatic, this means that your service will be started automatically when windows starts, and not when the installutil completes.
If you want to start it after the installutil, you will need to run installutil first, and then run
sc start <your_service_name> Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
|
|
|
|
|
You could also try creating a Setup Project where you run code to start your service as a Custom Action.
ServiceController sc = new ServiceController("yourServiceName");
sc.Start();
|
|
|
|
|
Hi, I got round that by adding a line into the projectinstaller.cs file.
(Sorry, I hope I get the formatting right, I am new to contributing to this kind of forum.... and pretty new to C# and programming in general)
After the statement:
Public ProjectInstaller()
{
InitialiseComponent();
}
I Added the following:
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
ServiceController controller = new ServiceCOntroller("//Service Name");
controller.Start();
}
You will also need to add using System.ServiceProcess; at the top of the file.
I hope this helps, it took me a while to find the answer searching google.
It works a treat for me.
|
|
|
|
|
if i have an xml file of the following schema : <users><user><username><password><userpicture><game><gamename>
<played><highscore>
to note that the played part take a value 0 or 1 (false or true) , so if i want to get to the the game part and set the gamename, played and highscore what method should i use (knowing that i have many players)
|
|
|
|
|
1. You haven't shown your XML.
2. IMHO, XML forum would have been a decent choice.
3. Going by the information I have, I would go for XPath."No matter how many fish in the sea; it will be so empty without me." - From song "Without me" by Eminem
|
|
|
|
|
You can start by using a descriptive subject line. XML is not very descriptive of you problem
Next clarify your question I know the language. I've read a book. - _Madmatt
|
|
|
|
|
<Users><User><Username></Username><Password></Password><UserPicture></UserPicture><Game><GameName>
</GameName><Played></Played><HighScore></HighScore></Game></User></Users>
|
|
|
|
|