|
There's no real good place to post this, but I'm having trouble with a SQL query:
SELECT Task.Tasknumber,ScheduleItem.HoursScheduled / HourTotals.HoursScheduled AS PlannedValue, (ScheduleItem.HoursScheduled / HourTotals.HoursScheduled * 1) AS EarnedValue<br />
FROM ScheduleItem INNER JOIN (ScheduleItem.TaskId = Task.TaskId) CROSS JOIN HourTotals<br />
GROUP BY Task.TaskId,Task.Tasknumber,ScheduleItem.HoursScheduled,HourTotals.HoursScheduled
I want the value of EarnedValue to be zero of HoursNeeded in ScheduleItem is higher than zero. Anyone know a trick in SQL to do this? Or should I make that function in C#?
WM.
What about weapons of mass-construction?
|
|
|
|
|
|
Thanks that worked out great. I found out how to do cummulative queries to.
Lets see if I can get that to work too.
WM.
What about weapons of mass-construction?
|
|
|
|
|
I setup an HScrollBar as part of a panel. Let's call this ScrollBar MyScrollBar. Now to the problem: When a user scrolls (dragging the slider) the maximum value that can be reached is not the MyScrollBar.Maximum value but the value (MyScrollBar.Maximum - 9). This occured for any MyScrollBar.Maximum value I specified. Anyone having this bug, too? Anyone know, how to fix this?
Greetings
|
|
|
|
|
This is quoted from MSDN:
The value of a scroll bar cannot reach its maximum value through user interaction at run time. The maximum value that can be reached is equal to the Maximum property value minus the LargeChange property value plus 1. The maximum value can only be reached programmatically.
So in your case LargeChange=10. You could get round this by adding LargeChange to Maximum;
-- modified at 16:12 Sunday 25th June, 2006
|
|
|
|
|
Thank you, didn't guess this is intended behaviour.
|
|
|
|
|
I have an object which is just a thin wrapper over an other object and might be created in big quantities.
something like that:
// ===== pseudo-code cample =======
class TheObject
{
int[] data;
TheWrapper Data { get { return new TheWrapper(data); } }
}
class or struct TheWrapper
{
int[] data;
public TheWrapper(int[] data)
{
this.data = data;
}
public int Length { get { return data.Length; } }
public int this[int index] { get { return data[index]; } }
public int UtiliyOneLikeSearch() {}
//... etc ...
}
// ========= end of pseudo-code sample ==========
Now it is very likely that aTheObject.Data would be called many times used for a few lines and forgot.
I thought it might be much more efficient memory wise to make TheWrapper a struct.
but somehow I feel it's quite unconventional.
what do you think?
|
|
|
|
|
Super Lloyd wrote: I have an object which is just a thin wrapper over an other object and might be created in big quantities.
Super Lloyd wrote: I thought it might be much more efficient memory wise to make TheWrapper a struct.
That makes good sense. This CP artcile[^] has compared class with struct.
Best,
Jun
|
|
|
|
|
let's do it!
|
|
|
|
|
Yes, using a struct would give you slightly less overhead, as there is one object less to create. Creating objects are not very expensive, though.
Generally a struct would only contain value types, not objects. When assigning a struct you copy all the data in it, but if it contains objects only the references will be copied. This is not consistent with how you expect a value type to work, so it might be pretty confusing.
If you want to make your code more efficient, I believe that there are other things that you could do that would increase the performance much more.
---
b { font-weight: normal; }
|
|
|
|
|
it's just 4 letters to replace, I could do it anytime
but yes, my worry is the slightly unintuitive behavior of this struct you so clearly outlined...
|
|
|
|
|
How to display all the image files in a directory? Even with the for loop below, I only get one image file displayed. I don't know if the problem lies in the location of the picturebox1. Can anyone please help?
int y = 5;
foreach (String file in files)
{
if (file.Contains(".jpg"))
{
System.Windows.Forms.PictureBox pictureBox1 =
new System.Windows.Forms.PictureBox();
picture.Controls.Add(pictureBox1);
pictureBox1.ImageLocation = file;
pictureBox1.Location = new System.Drawing.Point(6, y);
pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
y = y + pictureBox1.Size.Height + 5;
}
}
|
|
|
|
|
Hi,
I can't see anything wrong with the code above. What control is picture ? I'm assuming it's a panel or something. Might be handy to post the code used to gain the list of files.
|
|
|
|
|
It's a tabpage control. I debug it through and found that the size of the picture box has not changed to the size of the picture (I guess this is what it should be by using autosize mode). From this I would assume the new picture box is added on top of the existing one with exactly the same size each time.....
|
|
|
|
|
Do you mean you get just one PictureBox with one image, or many PictureBoxes all with the same image?
|
|
|
|
|
It seems to me that the new picture box is added on top of the existing one with exactly the same size each time. That's why I only see one image.
Setting the sizemode to autosize doesn't change the size of the picture box??
|
|
|
|
|
Hello
If I were you I'd use a foreach loop to check the parent.Controls for the next:
1- Make sure that the pictureboxes are all added up tto the parent successfully
2- Make sure of the ImageLocation property of each Picturebox
3- The size and location of each picturebox
This may clarify the problem. If it's like you said, simply calculate the size manually each time by calculating the image's size -ie. don't rely on AutoSize"
Happy programming;)
|
|
|
|
|
hi
i want to save avi file on hdd with encryption.then load it to my app as stream and decrypt it and play .how to do that ??
avi file --> encryption --> save on hdd or cd --> load to memory as stream --> decrypt --> play
|
|
|
|
|
I'm reading a book on "Prefactoring" and the author suggest converting primitive types to classes such as:
CommonString State;
CommonString ZipCode;
You can't assign these without the 'new' keyword in C# though, right?
So my idea was to create the types and load their verifying Regex's from a Xml file.
|
|
|
|
|
Seems a strange move to me. For me, state and zip code are easily represented by string. And creating a wrapper for a primitive type is useless as at some point you will need to interact with the primitive type (in some manner).
Classes can't be created without use the new keyword. (Although you can do with reflection)
-- modified at 16:22 Sunday 25th June, 2006
|
|
|
|
|
I read your question and here are some of my thoughts from the top of my head...
I think what you suggest would be a really good approach if you anticipate having a lot of validation and stuff going on.
>You can't assign these without the 'new' keyword in C# though, right?
That's right however you can hide the 'new' call inside an static public method in
the class that you want to create. This is part of the approach when implementing the singleton pattern in C#.
If you like you can add static methods that create your information classes if you think it is ugly with the 'new' keyword. By using this approach you can be more precise about how the object is initialized than if you use oveloaded constructors (where you would have to look up the parameters for the constructor).
For instance
StateInfo stateInfo = StateInfo.LoadFromXml("state.xml");
might be better than
StateInfo stateInfo = new StateInfo("state.xml");
By using a class for each type of information you can also make use of an refactoring called the "Null Object". This means that instead of initializing your StateInfo members to null, you set them to StateInfo.Empty. Now any checks for null is unneccessary and you can implement default values for when the info is missing. For instance the ToString metod return "<no state="" info="" entered="">" or something. This can lead to simpler and more readable code.
If you want to Load any validation RegEx or something for the class you could do that in a static constructor. A static constructor is called once (and only once) when the class is accessed the first time (even if it is through static functions).
Some sample (pseudo-)code:
class StateInfo
{
string m_StateName;
public static StateInfo Empty = new StateInfo("<no state="" entered="">");
public static StateInfo LoadFromXml(string xmlFileName)
{
StateInfo stateInfo = new StateInfo("");
//Init the stateInfo from file...
return stateInfo;
}
public StateInfo(string stateName)
{
//Do instance initialization here
m_StateName = stateName;
}
public static StateInfo()
{
//Called once
//Do class initalization here
}
public override string ToString()
{
return m_StateName;
}
}
So go ahead and use a storage class for your different types of information. I would however recommend that you don't "over design" your system to begin with. Instead go with a light design and refactor it as you go along.
Just some advice as requested, I hope it makes sense!
Have fun!
/Richard
|
|
|
|
|
Thank you very much for the replies.
|
|
|
|
|
it be possible to copy the songs off the iPod ?????????????????????
ahmed elshafee
|
|
|
|
|
ya, it is possible.
try connecting the USB and perform normal USB operation. by USB operation I mean. file transfer thru C# or I/O operations using C#. this requires USB and IPod drivers to be installed. as you connect the IPod operates as a drive.
|
|
|
|
|
hi there.
I was wondering if there is a way (other then looping tru all controls on a window) to get a control by its name.
for example if my window contains txtName (textbox) I would like to get the control by 'txtName'
Thanks :->
|
|
|
|