|
Reflection
i have this class
class A
{
public int a
}
now this is what i want to do in my method
private A copy(A first)
{
A second as new A()
now i want to copy all values from "first" tot "second" , like this i mean:
second.a = first.a
but on this way i don't want to work, when a new member is added, i always have to adjust this function
so i want to loop all members with reflection and then copy the value like this:
Type typea = Type.GetType("A")
For Each member As System.Reflection.MemberInfo In typeA.GetMembers(Reflection.BindingFlags.DeclaredOnly)
'and here i want something like this: (offcourse this doesn't work)
second.member.name.value = first.member.name .value --> how can i get something that does this with reflection
Next
}
|
|
|
|
|
Why not use the method MemberwiseClone?
---
b { font-weight: normal; }
|
|
|
|
|
yezz i also tought of that but what will happen with arrays of reference types?
class A
{
public z = new Z[4]
}
class Z
{
public h = new H[3]
}
class H
{
public int i
}
how does memberwizeclone clone this? my new object may not referece to the same objects, never!! because i will change some values, and my source object may not change along with it
|
|
|
|
|
Then you have to loop through the members of the class and create a copy of each member that is a reference type. The code has to handle all data types that you will be using in the class.
I would have let the class implement IClonable instead.
---
b { font-weight: normal; }
|
|
|
|
|
can't do, i don't have control over the class, i'm only using it
so i think the only way doing this is with reflection, so if someone knows how i have to code this, please
|
|
|
|
|
is there any property for writing something to masked textbox without deleting what it includes.
Like YOU CLICKED INSERT KEY
|
|
|
|
|
in a project i used maskedtextbox, i am using .net FW beta 2 . In XP computers there is no problem, but at Windows ME computers have problem.
Problem is When u enter maskedtextbox -while using directionb keys- cursor isnt gone where u want to take it.
|
|
|
|
|
Hi all,
I am developing an Editor on Japanese XP and want to provide text formatting in the editor.
I provided a comboBox to select the Font. i have included some Japanese fonts such as MS Gothic, SimSin, SimHei etc..
Now the problem i am facing is when i change the font from the ComboBox the font is not changed i.e the change is not reflected
The text entered after changing the font has the default font instead of the new font that is selected.
any help will be appreciated
Thanks and Regards,
Pramod
|
|
|
|
|
Yadav Pramod wrote: i.e the change is not reflected
Did you provide code for the combobox' itemChange event? If yes, what code did you write in there?
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
This is in the selectionChanged event of the ComboBox
{
RichTextBoxEx temp = focused; //focused is the RichtextBox that is currently focused
if(temp.SelectionFont != null)
temp.SelectionFont = new Font(((ComboBox) sender).Text,
.SelectionFont.SizeInPoints,temp.SelectionFont.Style);
else
temp.Font = new Font(((ComboBox)sender).Text,
temp.Font.SizeInPoints,temp.Font.Style); temp.Focus();
}
Please reply if u have some solution
Thanks and Regards
Pramod
|
|
|
|
|
Hmm... you said you're using Japanese font families. Are they installed on your machine? A simple way to find out if they are indeed, is to fire notepad and see if you can use them to write something. If not, I think that's ur problem.
I've tried adding a richTextBox and a combo on a form with the code below and works fine. Notice that in the form's load event, I get only the installed fonts on my machine, and use one of them to apply to my richTextBox:
private void Form1_Load(object sender, System.EventArgs e)
{
foreach (FontFamily f in FontFamily.Families)
this.comboBox1.Items.Add(f.Name);
this.comboBox1.SelectedIndex = 0;
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.richTextBox1.Font = new Font(this.comboBox1.Text, 10);
}
Regards,
Polis
Can you practice what you teach?
-- modified at 7:44 Friday 9th December, 2005
|
|
|
|
|
Hi Polis,
i have installed Japanese XP on my machine and i have all the japanese
fonts installed on it.
Any more suggestions or ideas
Thanks and Regards,
Pramod
|
|
|
|
|
You are using the SelectionFont property, which will only change the font of the current selection... I think for the whole box set the Font property.
|
|
|
|
|
Hi, Thanks J4amiec
I dont want to set the new font to the Whole textbox
but it should be reflected only for the text that will be written after changing the font
If i set this to the Font property then the text which was written
earlier with someother font also changes
please if anymore idea
Thanks
Pramod
|
|
|
|
|
Yup you are right, I tried a rich text box and a button, with this code on the button
private void button1_Click(object sender, System.EventArgs e)
{
this.richTextBox1.SelectionFont = new Font(this.richTextBox1.Font.FontFamily,this.richTextBox1.SelectionFont.Size+10);
}
And it worked fine... each time i clicked the button, further typing in the box was bigger. Have you tried running through your code with the debugger to see that everything is being set correctly?
|
|
|
|
|
Ya i have debugged it many times
but still cannot find any error in the code
this gives problem only Japanese O.S
it works fine on Windows Proffessional 2K
Thanks
Pramod
|
|
|
|
|
Hi all,
Can anybody help me how to tile a texture in managed directx?
The texture i draw on my surface is stretched, and it does not look very nice?
What are the device settings needed to tile/wrap a texture on a surface??
Thanx all
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
I think you get more help over there
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi everyone,
I did a windows application using c#. If I want to distribute this as trial version software that is after certain period the application should not work, is there any tools or features to do this in c#???
Otherwise how can I do it? Can you tell me? Thanks. Bye
|
|
|
|
|
Hi,
you can do one thing
Check the current system date when the application is loaded and
execute it further only if the date is less than the required date
else exit the application by giving the error message
Regards,
Pramod
|
|
|
|
|
Hi,
thanks for your reply Yadav. Yes. I can do it. But what I did is, actually its a screen saver application. So I changed the application'e exe file extension from .exe to .scr and placed that .scr file into system32 folder when deployment process. So how can I control this .scr application?
|
|
|
|
|
Hi,
You have changed the extension from .exe to .scr but
whenever the executable is invoked it will execute in the same way so you can
do as i said earlier and that will work. it doesn't matters if the file is .exe or .scr
Regards,
Pramod
|
|
|
|
|
ok. But how Windows able to understand it as a screen saver file if its extension is exe file?
|
|
|
|
|
Basically the screensaver executes that means it is an exe and you dont need to worry for that windows will handle it
Regards
Pramod
|
|
|
|
|
Hi there,
Basically i'm a noob with C# and web service, and i'm working on my project of building a C# web service to connect between a supplier system and a client system.
For example, a making order task would involve the client system sending that order data to the web service and from there it will relay the information towards the supplier system. I know basically how to send data and receive data from the web service by button clicking event. So the first part shouldn't be a problem. But how do i get it to relay data from the web service to the other system?
And the supplier system is built using c# and sql server, while the client systems which consist of a java with mysql system and another vb.net with ms access. I plan to use the basic template wdsl that is provided by the .net framework, is there going to be any problem connecting to the java system?
Thanks in advance~
"Better live as a horse than the goose."
|
|
|
|