|
I have no clue at all.
Maybe you should try the ASP.NET forum?
|
|
|
|
|
Hi,
Is there any difference in the following with regards to security?
private int _orderId;
public int OrderId
{
get { return _orderId; }
set { _orderId = value; }
}
...and...
public int OrderId { get; set; }
When should we use the one and not the other?
Regards
|
|
|
|
|
.NET Enthusiast wrote: Is there any difference in the following with regards to security?
No. The only difference is compiler will generate the backing field for automated properties.
.NET Enthusiast wrote: When should we use the one and not the other?
If you want more control over the getter and setter, you need to use the first one. For example, when OrderId is set, you need to fire an event. Something like,
private int _orderId;
public int OrderId
{
get { return _orderId; }
set { _
orderId = value;
PropertyChanged();
}
} In all other cases, automated properties are just fine.
Best wishes,
Navaneeth
|
|
|
|
|
Thanks Navaneeth
|
|
|
|
|
In addition to the already correct answer you have, when using automatic properties you must have both a getter and setter. If you wish to have a read only property you have to mark the setter as private. If using your own backing field you only have to provide the getter.
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)
|
|
|
|
|
I have recently updated to Vis 2008 and after converting some of my code that utilizes the axmediaplayer the code no longer works properly.
I have an event handler for the AXmediaplayer called wmp:
this.wmp.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(this.player_PlayStateChange);
Which in the 2005 code triggers this event:
private void player_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
MessageBox.Show("PLAY STATE = " + e.newState);
// There is more here
}
When converted to Vis 2008 the event is no longer triggered.
|
|
|
|
|
Problem solved.
You need to reload the COM components for the Windows Media Player after conversion.
|
|
|
|
|
hi.
i m new in crystal report i want to make stock report please give me some idea how i can make this report.
|
|
|
|
|
Hello again,
my problem is: I have a printPreviewDialog control and I want to print: a bitmap (dimensions: 650x500, as a background), and some dynamic text (added afther the bitmap, to be visible).
My application is working perfect, but I experience a wierd thing: I want to set my printPreviewDialog to print on A4 paper size.
I've configure this as below:
PrintDocument pd = new PrintDocument();
pd.DocumentName = "Doc1";
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.DefaultPageSettings.PaperSize = new PaperSize("PaperA4", 826, 1169);
printPreviewDialog1.Document = pd;
On pd_PrintPage method I've write the code of what I want to print.
Now the wierd thing: when I start the app and open the printPreviewDialog, it seems ok! Paper size = A4, all is right!
But when printing the paper size is Letter!!!!!!! Only 90% of my print document is printed! It seems the page I want to print is to big for A4 size!
Why is that? I'm missing something? How can I right configure this for A4 paper size?
Cheer's,
Alex Manolescu.
|
|
|
|
|
Hello
I always use Microsoft Report for printing my documents and picture I dont have any problem with it
if you use this component you'll find it this easy and always work with it
if you don't know about it send a message, I and most of members can tell you aboute how you can work with excellent Microsoft Report Component
|
|
|
|
|
Thanks you for answer!
I'll try Microsoft Report Component.
|
|
|
|
|
While trying to create a UserControl I attempted to include code to change the Size and Location properties inherited from Control. The IDE didn't like that, complaining that these properties could not be modified. So I assumed that these must be abstract members and added overrides in my control with get/set accessors. While this doesn't produce an error, it does emit a warning about my variables 'hiding' the properties in the Control base class. Am I doing this wrong, or is this the normal way to control these properties? I guess I should also ask, if I want to add programmatic access to other properties in the base class, do I need to handle them in the same way?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Confused me this. I would expect you to be able to change Size and Location on a UserControl without issue.
Where abouts are you trying to change these properties? In the UserControl itself or elsewhere? When you say the IDE complained that the properties could not be modified, what was the exception message?
Regards,
Rob Philpott.
|
|
|
|
|
I was trying to change these values in the constructor, and to provide functions within the control to change them. Apparently the correct way to do this is from the outside, not inside the control. In retrospect, the only thing I really need to do in the constructor is to access the Size property in order to scale the visual elements of the control.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I'm not sure I understand your question.
Does the following not work for you?
var myUsercontrol = new UserControl1();
myUsercontrol.Size = new Size(130,150);
myUsercontrol.Location = new Point(10,30);
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Good question - I never tried that. Nick's post below identified what I was trying to do, and explains nicely why it didn't work. The book I'm using to learn this is quite insistent that the class UserControl is very important, then skimps on explaining how to make one. An unusual flaw, given the quality of the rest of the book.
Thanks!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I rarely use UserControl as most things I need to do can be done by using either Control (UI controls) and drawing everything I need myself, or Component (no UI required).
UserControl derives from ContainerControl so it's handy for using the designer for drag 'n' drop of other controls to make a composite control.
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)
|
|
|
|
|
I've been thinking about your response all day, trying to figure out where my reasoning has gone wrong. I selected UserControl as a base class only because the book I'm using as a guide recommends it. But your point about using Control as a base and drawing what's needed actually fits my needs more closely. What I'm trying to create is a reusable control that provides a Gannt chart style of scheduling bar. I'm using a rectangle for the task duration, overlaid with another rectangle to show the progress, with triangles at each end to mark the start and finish points. Each triangle also contains an anchor point to allow it to be linked to other dependent tasks. These are just graphical objects that need to be manually drawn, and your approach seems more logical. Where I'm getting stuck, I think, is in scaling the graphical objects in response to changes in the size of the base object, and in placing the control on a form. These changes would always be at design-time, never in run-time. But the control does need to respond to run-time changes in duration and progress.
Can you suggest an approach that you would use in implementing this control? This is my first attempt in C# at creating a control, and it's already been quite instructional. Your insight would be much appreciated.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
It does sound like the bar should derive from Control , and a chart of many bars would probably derive from ContainerControl , although it's quite possible to have just the one control which handles both, which would then derive just from Control .
If just the one control then scaling would be easy as you can do everything as a percentage of the Size/ClientSize. I think this method would be the easiest, but not necessarily the most flexible.
If you want the first method, then you may have to allocate each bar a space in the Chart container dynamically and call a custom ResizeRequest(Size maxSize) method in the bar, or something similar. Normally containers draw what they can but have no responsibility for resizing the contents and simply don't draw what won't fit.
It may be worth examining the .NET source and seeing how Dock and Anchor are implemented as it seems to be similar to what you want to do.
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, Dave!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
This will not work:
Size.Height = 100;
Size.Width = 100;
Location.X = 100;
Location.Y = 100;
This is because Size is a System.Drawing.Size and Location is a System.Drawing.Point . Both of these types are struct s, which means that they are passed by value not by reference.
So when you write:
Size size = Size;
Point location = Location;
you are actually getting copies of the structs, not a reference to the original data.
This means it makes no sense to try to change, say the Height of the copy of the Control's Size and the compiler flags this as an error for you.
As Eric said, you can replace the underlying Size and Point like this:
Size = new Size( 100, 100 );
Location = new Point( 100, 100 );
This works because in the Control class, the properties have setters as well as getters:
partial class Control
{
public Size Size { get; set; }
public Point Location { get; set; }
}
Now, if you add new properties to your Control called Size and Location, they have no relation to the base class properties with the same names. The new properties just 'hide' the base class properties. The compiler warns you about doing this, as it is legal, although confusing and not recommended. You can add the new keyword to get rid of the warning, but this is also confusing and not recommended.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Thanks, Nick! That makes perfect sense.
Your first example is exactly what I was trying to do.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Sometimes you can override the base classes properties, other times it is necessary to replace them using the new keyword.
In the case of Size , Control uses another readonly property DefaultSize alongside to set the initial size so that needs to be dealt with too. I've never needed to change the Location property inside the control itself as it is normally accessed by the control's host for layout within it's client area - I can't think of a reason to need to replace the default behaviour of this property.
Here's an example using new , override and an additional property
public class MyControl : Control
{
public event EventHandler IDChanged;
private static readonly Size MyDefaultSize = new Size(150, 50);
public const int MaxID = int.MaxValue;
public const int MinID = 0;
private int id;
public new Size Size
{
get { return base.Size; }
set { base.Size = value; }
}
protected override Size DefaultSize
{
get { return MyDefaultSize; }
}
public int ID
{
get { return id; }
set
{
if (value < MinID || value > MaxID)
throw new ArgumentOutOfRangeException(
"ID",
string.Format(
"ID must be between {0} and {1}",
MinID, MaxID));
if (id != value)
{
id = value;
OnIDChanged(EventArgs.Empty);
}
}
}
protected virtual void OnIDChanged(EventArgs e)
{
EventHandler eh = IDChanged;
if (eh != null)
eh(this, e);
}
}
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 the excellent example, Dave.
I was thinking, for some odd reason, that I needed to handle location and setting myself in the constructor, rather than relying on the base class to do it for me.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
i have to check if my string span to more than one lines than append space at start of each line..hw can this be done?
Regards
Ali
|
|
|
|