|
I have a problem in undo & redo of custom controls...I have a custom control object that needs to be cloned into a new object when redo is done.
Am using the following method :-
In the below method "ctrl" is the New empty object to which the properties have to be copied from "propertyList"(Properties of Old object)..
But the following line throws an exception 'Unable to convert System.Reflection.RuntimePropertyInfo to System.Drawing.Point' when trying to copy AutoScrollOffset property.
lINE ->myProperty.SetValue(ctrl, obj );
Is there a way to convert a property(whatever be the type ) to the corresponding property in the new object ?????....
public static void SetControlProperties(System.Windows.Forms.Control ctrl,Hashtable propertyList)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(ctrl);
foreach (PropertyDescriptor myProperty in properties)
{
if(propertyList.Contains(myProperty.Name))
{
Object obj = propertyList[myProperty.Name];
myProperty.SetValue(ctrl, obj );
}
//...
}
}
|
|
|
|
|
Hello,
PropertyDescriptorCollection pdcoldControl = TypeDescriptor.GetProperties(oldControl);
PropertyDescriptorCollection pdcnewControl = TypeDescriptor.GetProperties(newControl);
foreach(PropertyDescriptor pdoldControl in pdcoldControl)
{
if((pdoldControl.Attributes.Contains(CategoryAttribute.Appearance) && pdoldControl.IsBrowsable)
|| (pdoldControl.Attributes.Contains(CategoryAttribute.Behavior) && pdoldControl.IsBrowsable && pdoldControl.IsReadOnly==false))
{
PropertyDescriptor pdnewControl = pdcnewControl[pdoldControl.Name];
pdnewControl.SetValue(newControl,pdoldControl.GetValue(oldControl));
}
}
TypeDescriptor.Refresh(oldControl);
TypeDescriptor.Refresh(newControl);
newControl.Size = oldControl.Size;
newControl.Text = oldControl.Text;
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hi,
Thanks for ur help. I have implemented your method but with this method, i am not able to clone the object along with its member variables. In order to do that, i had inserted public properties for the member variables so that i could use the suggested method to copy these properties(indirectly copying the member variables also). But one of those members is of type XMLHandler, which is a custom serializable class to read values from an XML File. when i execute the system throws an exception 'System.XML.XMLElement is not marked as serializable'.
Please help me find a way to clone the object with its member variables or fix this exception.
|
|
|
|
|
Hello,
I think you have to try to cast the object with "ISerializable" class (best way is with the "as" operator) and than ask if its "!=null".
All the best,
Martin
|
|
|
|
|
How to make a listview looks like the windows explorer?
Just look the picture at
http://goldli.s75.53dns.com/desktop.jpg
the listview item can be splited by
http://goldli.s75.53dns.com/desktop1.jpg
or
http://goldli.s75.53dns.com/desktop2.jpg
if you can not see the pictures ,please send me a mail : goldli@tom.com
|
|
|
|
|
simply, add image list with some icons, create items there (by hand in listview tasks, or programatically), columns... and groups...
VirtualVoid.NET
|
|
|
|
|
Hi,
I want to restrict copy and paste the text in a TextBox control. The user should not copy the text from TextBox control and should not Paste any text into TextBox control. The user can enter any data and can delete. How can I do this in C#?
Thanks in Advance,
Reddy.
rr
|
|
|
|
|
Hi,
Pls see this link, this should help you out.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=741989&SiteID=1
Best regards
Omkar Ghaisas
|
|
|
|
|
Hi Reddy,
I couldn't restrict copy and paste in a textbox but colud restict copy and paste
on whole form.
here's the solution
add oncontextmenu="return false" to the body tag
Naveen G
MCSD.Net
|
|
|
|
|
Hi,
I was just wondering about how is Instantiating of a value type allowed in .NET
We know that Class is a Reference type and so we can create an object of it i.e its instances. But how is it possible for a Value type like int, Struct ?
When we type in int Counter = new int(); what does actually happen ?
Can anyone guide me. Pls correct me if I am wrong somewhere.
Thanks and best regards
Omkar Ghaisas
|
|
|
|
|
You don't need to use new with value types
only two letters away from being an asset
|
|
|
|
|
Hi,
I know that we don't use new on value types, but if we try to use that in actual editor, then it doesn't throw any error either. Then what exactly happens when we type in int Counter = new int();
Pls guide me.
Omkar Ghaisas
|
|
|
|
|
Please reade .Net FrameWork CareFully.
|
|
|
|
|
Mark Nischalke wrote: You don't need to use new with value types
How do you create a Point without new ? Point is a value type.
|
|
|
|
|
You're correct. I meant in the case he had; int somevalue = 0; would do, no need for new.
only two letters away from being an asset
|
|
|
|
|
|
I have just got the requirements to develop a project using .NET and c# codings. I have a good knowledge on database and UI. But i'm not able to understand the codes of C# very well... Can anyone tell me how to add C# files to ASP.NET, how to use methods and classes written in c# along with the business layer of ASP.NET.
|
|
|
|
|
HI
C# is a language. If you are using ASP.net then it can be done in many languages C# is one of them .............
Its very easy if you know C++ or java try to do some tutorials on C# and Google rest of the things Best Luck
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
priychai wrote: Can anyone tell me how to add C# files to ASP.NET, how to use methods and classes written in c# along with the business layer of ASP.NET.
You might want to read some tutorials on the subject. That's an awful lot to answer in a forum post.
Incidentally, ASP.NET sits on the presentation layer. You would be writing the business layer.
|
|
|
|
|
Hi,
Can I render text using postscript font directly.?
Without using any other third party tool or dll.
I am trying to render text on the form using postscript font ,but yet not able to do it.
If anyone of you can give me suggestion in this ,it would be great help.
Eagerly waiting for response.
Thanks in advance.
|
|
|
|
|
I have a class MyDataGrid which is inherited from Datagrid
which have two protected override functions.
i want to register the events.
for example
public class MyDataGrid : DataGrid
{
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
{
//dosomething
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
//dosomething
}
Now i want to register these events
i m registering as
this.dataGrid1.MouseDown+=new System.Windows.Forms.MouseEventHandler(this.OnMouseDown);
this.dataGrid1.MouseMove+=new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
error is
Method 'System.Windows.Forms.Control.OnMouseDown(System.Windows.Forms.MouseEventArgs)' does not match delegate 'void System.Windows.Forms.MouseEventHandler(object, System.Windows.Forms.MouseEventArgs)'
Method 'System.Windows.Forms.Control.OnMouseMove(System.Windows.Forms.MouseEventArgs)' does not match delegate 'void System.Windows.Forms.MouseEventHandler(object, System.Windows.Forms.MouseEventArgs)'
can anybody tell me waht's the solution?
i m coding in C# Windows application ,version 1.1(2003)
|
|
|
|
|
Hello,
bhavna816 wrote: Now i want to register these events
i m registering as
this.dataGrid1.MouseDown+=new System.Windows.Forms.MouseEventHandler(this.OnMouseDown);
this.dataGrid1.MouseMove+=new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
Where?
Hope not in the derived class!
You should also call the base methods inside the overriden methods!
All the best,
Martin
|
|
|
|
|
if u can see the second URL
the code is
public class MyDataGrid : DataGrid
{
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
{
// Get info to determine which cell to inspect.
DataGrid.HitTestInfo hti = this.HitTest(new Point(e.X, e.Y));
if(hti.Type == DataGrid.HitTestType.ColumnResize)
{
return; //no baseclass call
}
base.OnMouseMove(e);
}
|
|
|
|
|
Ok,
But that's not the real point.
Where are you doing
MouseDown+=.....
MouseMove+=.....
And how does the method look like which is linked?
All the best,
Martin
|
|
|
|
|
funtion definition should be same when ever you override any function.
number of arguments are different. it should be like
protected override void OnMouseDown(object sender,System.Windows.Forms.MouseEventArgs e) <br />
{ <br />
}
|
|
|
|