|
Hi,
1.
you don't need to create a special list class, a simple:
List<SnapShot> snapShots=new List<SnapShot>();
SnapShot snap=new SnapShot(...);
snapShots.Add(snap);
...
List<SnapShot> moreSnapShots=new List<SnapShot>();
moreSnapShots.Add(...);
snapShots.Add(moreSnapShots);
would work just fine.
2.
And you could make that slightly more user-friendly with an almost empty class like this:
class SnapShotList : List<SnapShot> {}
SnapShotList snapShots=new SnapShotList();
SnapShot snap=new SnapShot(...);
snapShots.Add(snap);
...
SnapShotList moreSnapShots=new SnapShotList();
moreSnapShots.Add(...);
snapShots.Add(moreSnapShots);
|
|
|
|
|
Thanks very much Luc. I will take a look into this.
As for snap , this is of the type SnapShot as defined via the SnapShot class's SnapShot function?
Thanks,
Matt
|
|
|
|
|
bbranded wrote: as defined via the SnapShot class's SnapShot function?
yes.
however functions are passé, you should call them methods now; unless they are constructors!
|
|
|
|
|
5ed
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Haha! What do you call a Lambda Then Luc?
|
|
|
|
|
I'm afraid I can't answer that on a public forum.
|
|
|
|
|
bbranded wrote: I'm a little lost as to how to write a class that will take in arguments from the .Add function of a List<>.
If you use List, then do not handle .Add, because it is implemented. As your example you incorrectly defined List.
List<SnapShot > LiveSnapshot = new List<SnapShot>();
|
|
|
|
|
public class SnapShotList : List<SnapShot> {}
Then you can do this:
SnapShotList snapshots = new SnapShotList();
As a result, you get all of the benefits of having a list (including all of the methods therein) in a conveniently named object, and you can add specific custom behavior to your class to handle circumstances ragarding the items in the list. I do it all the time.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I am developing a Custom Control and I will ask question from several categories. I appreciate your answers
1st question:
How can I create a class to be used like XmlNode. XmlNode can be XmlElement or other types. I wan't to use similar approach. I need it, because I want draw other type of controls within one control.
Example:
Display a Group box with a picture and a button as an item in TreeView
2nd Question:
My Control is Inherits Control class. How can I hide some properties and/or change its description.
Thank you for your time.
|
|
|
|
|
Saksida Bojan wrote: 1st question:
How can I create a class to be used like XmlNode. XmlNode can be XmlElement or other types. I want to use similar approach. I need it, because I want draw other type of controls within one control.
Okay, well then create a simple interface for your object and have a toString method that can convert it to the correct output. Look at the XML classes and interfaces, they all share a common.
Saksida Bojan wrote: Example:
Display a Group box with a picture and a button as an item in TreeView
This is more complex. You would have to use some kind of logic to display the node as such. HTML/WPF/SilverLight/WinForms all do it differently. Look for some examples on:
Creating User Controls.
Saksida Bojan wrote: 2nd Question:
My Control is Inherits Control class. How can I hide some properties and/or change its description.
In the designer. All properties are visible. You can change them there, there will be somethings you can't hide or change depending on the inheritance of the object/control.
Question: What are you creating the control in? WPF?
|
|
|
|
|
TheArchitectmc∞ wrote: Okay, well then create a simple interface for your object and have a toString method that can convert it to the correct output. Look at the XML classes and interfaces, they all share a common.
Will look at it. If I coudn't use, then I would use Object, but I would rather avoid Object
TheArchitectmc∞ wrote: This is more complex. You would have to use some kind of logic to display the node as such. HTML/WPF/SilverLight/WinForms all do it differently.
I have already thought on how to handle it
TheArchitectmc∞ wrote: Look for some examples on:
Creating User Controls.
I have read a Book about creating Custom control, however i need data layer that behaves like XmlNode. I will look at the interface.
TheArchitectmc∞ wrote: Question: What are you creating the control in? WPF?
I am desinging for windows form
|
|
|
|
|
Saksida Bojan wrote: I am desinging for windows form
Okay if you are designing for windows forms, then this has sort of been done for you in the WPF implementation of Windows Forms.
Create a WPF application, add WinForms to the project, it appears as a button in the widget box.
Saksida Bojan wrote: I have read a Book about creating Custom control, however i need data layer that behaves like XmlNode. I will look at the interface.
There are many way of representing data as an XML node. Many converrters in the .NET runtime. Take a look at LINQ to SQL, LINQ to XML, and LINQ to Objects. There are ways to easily use SQL as XML, Object as XML.
Saksida Bojan wrote: Will look at it. If I coudn't use, then I would use Object, but I would rather avoid Object
Another approach to to directly inherit from XMLNode or what ever works for you. I would make sure that it is a basic enough object which can also be used in other assemblies in the .NET runtime.
|
|
|
|
|
1. You can either use an interface or an abstract class depending on what suits your needs best.
2. This is possible by creating new properties the same as the old and applying certain attributes (overriding instead of new may work - I seem to recall having problems that way). The control will need to be compiled to a separate assembly, if in the same assembly as the project, or in a referenced project then the attributes will have no effect!
public class MyControl : Control
{
[Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
EditorBrowsable(EditorBrowsableState.Never),
ObsoleteAttribute("This property is not valid for this control")]
public new string Text
{
get { return base.Text; }
set { base.Text = value; }
}
} This isn't foolproof though as the end user can always treat your control as Control and have access to all the stuff that Control has. It's also against OOP priciples to inherit stuff you don't want, but in the case of Control there isn't much option and even MS themselves do it!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
thanks for info. Gonna need to look into abstract, because i do not know what it is.
|
|
|
|
|
An abstract class is a bottom level class in the class hierarchy which can not be instantiated. So if you are using inheritance you won't be able to use abstract classes.
The attributes solution is a good hack to keep the user from using something you don't want them to use.
|
|
|
|
|
Hi All,
I have a Windows service that suppose to write in a file in a shared network drive.
Bud im getting this error:
System.UnauthorizedAccessException: Access to the path '\\Pc001\test\test.txt' is denied.
How can i fix this ?
Thanks
|
|
|
|
|
You have to give wright permissions to the shared folder.
|
|
|
|
|
Run the service under a user account insterad of Local System. Start -> Run -> services.msc and find your service, double-click it to get properties. On the LogOn tab, specify a user account that has permissions to that network share.
|
|
|
|
|
Hi Dave Kreskowiak,
Thanks for reply, i will try this your suggestions asap.
|
|
|
|
|
|
Noone is going to answer you because of 3 things. First, your subject line demanded an answer. That is very rude.
Second, noone can understand your requirements. I understand English is not your native language, so someone else better at translating would probably be appropriate.
You question seems to be so high-level and undefined and to only elicate more questions from anyone who reads it.
|
|
|
|
|
hi all
i am new about in c# and making a small project to improve myself and to learn new things...but as u can imagine i have a problem...i have a datetimepicker in my form and i keep the customer's birthdate with it...but it tries to save the birthdate to database like dd.mm.yyyy...i use sql server 2005 express edition for database and it keeps that data as yyyy.mm.dd so how can i get rid of that problem..i want it to keep data as dd.mm.yyyy...and i keep my data in database as smalldatetime...i dont want to keep it as string because maybe i will make someoperations on it later...thanks for your help now
|
|
|
|
|
Without seeing your code, it is difficult to answer accurately, but:
I assume from your brief description that you are using DateTimePicker.Text to access the selected date? If so, then DateTimePicker has a Value property, which is a DateTime.
Use code similar to the following to insert the date into the database:
DateTime dt = dateTimePicker1.Value;
SqlCommand cmd = new SqlCommand("INSERT INTO myTable (DateColumn) VALUES (@DT)");
cmd.Parameters.AddWithValue("@DT", dt);
...
You are absolutly right not to keep the date in the database as a string! A DateTime or SmallDateTime is much better.
[edit]Types wrong: should be DateTime and SmallDateTime[/edit]
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
hey man thanks for the reply
it works very well but i want to ask one more question which is the date is kept like in that format in database 2009-12-28 15:47:18.250
my first question is that if it causes any problem when i want to read it from my database ??
and second one if it is possible to change that format as 28.12.2009 15:47:18.250
|
|
|
|
|
You can convert date time in different formats,check this link[^].
Regards.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|