|
Beside what engsrini alrready said, you can think of it as an advanced way of dynamic coding. Currently it isn't widely used, but I believe in the future it may. One example is like making your own forms editor. Something like MS Access where your users can make a form and bind it to the Db. Maybe you want to add custom controls in your form.
Another example is using reflection as a mean of adding update capability in your program, where you dunamically instantiate a class from a dll and call certain methods. When you update all you need to do is to replace that dll. I know this is crap but it is possible.
One last thing is to use reflection to reference to a library that is not included in your program by default -for example optional downloadable plug-ins to your program-, and make error checking when using the classes in it. So that users can un/install plug-ins as suits them without changing anything in the main program. If a plug-in makes an error or was deleted by mistake, using reflection and not hardcoding the references into your program will give you flexibility and prevent your program from crashing.
That was some of the things I could come up with in 5 minutes. Creativity has no limits.
Regards
|
|
|
|
|
Lavanya
We have a business rules engine which allows us to bind in custom objects at run time. How this works is the customer develop a custom object that implements an interface called IBindingObject. The rules engine loads the object (using reflection), and verifies that it does indeed implement IBindingObject. We then use reflection to call other methods to find out and use the rule capabilities of the custom object.
HTH
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks guys. I am very new to this concept of reflection. and when i read abt it i was wondering how this could be used in real time apps. that is y i posted the msg. i got some idea now. thanks a lot.
|
|
|
|
|
hi i want to hide some of the nodes of the treeview based on some condition how can we implement that. There is no such property for a node to make invisible.
thanks.
|
|
|
|
|
There is no way to make a node invisible. You can remove the items you want to hide.
|
|
|
|
|
You could just override the DrawNode method, and based on a custom treenode tag or property, e.g IsInvisible, decide if the node must be drawn.
Diego Valdevino.
|
|
|
|
|
in my project i nedd the first root node invisible, my solution was stablishing margin-top:-30px, i tried finding on javascript but it didn't caught the css style neither the element.style.display="none" neither the element.style.visibility="hidden"
good luck
|
|
|
|
|
Hello,
I have a table with the primary key being a auto incremented value (IDNumber).
I need to retrieve the latest value that was inserted into the database.
So if the latest IDNumber is 100, I have to somehow pull this number from the database, so I can use it in my program.
The main problem is, if the program is first started I need to get this value.
I am using VS 2005 and SQL server 2005.
Is there a simple way to do this.
Thanks in advance,
Steve
|
|
|
|
|
fire a query which would fetch max of ur primary key column.
e.g.
Select Column1,Column2 FROM Table WHERE PrimaryKey = SELECT MAX(PrimaryKey) FROM Table
sameer
|
|
|
|
|
use IDENT_CURRENT( 'table_name' ) to get the last identity value generated for a specified table or view in any session and any scope.
Naveen G
MCSD.Net
|
|
|
|
|
Hi all,
I need to solve a problem for working with file in C#. I had a text file. It stores information of Customer. It is viewed:
Customer.txt
ID Name Address PhoneNO
1 Johnny Texax 1234567
2 Jackson NewYork 4562314
3 Bush LalsVG 4789633
4 Michael Maiami 7550751
.......................
Now, I want to add new Custmer into Customer.txt. But this Customer's ID is not the same Customer's ID exists in file. (the same ID in a table in database ).
Please help me!
Thanks!
|
|
|
|
|
You can read the text file as line by line and use the substring to spilt out ID from the string. use the following
<br />
File.ReadAllLines Method <br />
string[] s=String.Split (' ')<br />
then Compare every 3rd element in the array (s) ( C.ID) to check whether the CID is existing in the file or not.
Note : space delimit is important between the columns in the file
|
|
|
|
|
use xml file to store and retrieve value.it's a Good Practice to use xml file for structure data
sameer
|
|
|
|
|
If XML is not an option, you should have some kind of delimiter that distinguishes the fields. Then split the fields by the delimiter.
|
|
|
|
|
I was looking at the article written by Ian Giffen that he had written about the DragDrop event handler at http://www.codeproject.com/cs/miscctrl/LANDragDrop.asp[^ and I have developed a quite interesting challenge regarding how the application functions.
I am requesting that a DragDrop expert to download the source code application and to make the following modifications to the source code in order to reach the dilemma that I have encountered.
Make the following changes to the source code in the Form1 form.
Add a second control to the application like so:
public Form1()
InitializeComponent();
TestControl NewCtrl = new TestControl();
NewCtrl.Left = 50;
NewCtrl.Top = 50;
TestControl NewCtrl2 = new TestControl();
NewCtrl2.Left = 150;
NewCtrl2.Top = 50;
this.Controls.Add(NewCtrl);
this.Controls.Add(NewCtrl2);
DragDropHandler.Initialize();
DragDropHandler.RegisterControl(this, true, true);
DragDropHandler.RegisterControl(panel1, true, true);
DragDropHandler.RegisterControl(NewCtrl, false, false);
DragDropHandler.RegisterControl(NewCtrl2, false, false);
DragDropHandler.RegisterControl(button1, false, true);
}
Then in the TestControl.cs file make the following changes:
public TestControl()
{
InitializeComponent();
this.Width = 50;
this.Height = 50;
}
to make each control bigger. Now here is the dilemma. I would like each of the two controls: NewCtrl and NewCtrl2 to be able to act as parents to each other. That is, I would like to be able to drop one of the controls onto the other.
I have attempted to change the following code:
DragDropHandler.RegisterControl(NewCtrl, false, false);
DragDropHandler.RegisterControl(NewCtrl2, false, false);
to...
DragDropHandler.RegisterControl(NewCtrl, true, true);
DragDropHandler.RegisterControl(NewCtrl2, true, true);
and I have tried to catch the control in the DragOver event, but to no avail. The DragDrop event handler needs to have access to the parent control if one of the controls has been dropped onto the other control. This is the challenge. I am requesting the assistance of a DragDrop guru to resolve this dilemma. Please help!!!
|
|
|
|
|
How do you clear the write-protection on folders? I need to get a file from the IE cache to modify it. Thanks for any help.
-Fred Morstatter
|
|
|
|
|
Why would you want to change a file in cache? Why not just change the file on the web server? The next time your site is visited, the cache will be changed.
|
|
|
|
|
I wrote a custom menu control that accepts keyboard movement.
I have a form with a button on it.
When I click the button I see my menu pop up below the button.
The problem is that the focus shifts between the button and the custom control whenever I press an arrow key.
How do I keep other controls from stealing focus away from my custom control.
I don't want to disable other controls.
I want to maintain focus in my custom control
I've tried to set the handled and the suppressKeyPress functionality in the event but the button still grabs focus for every other keypress.
Any ideas?
Thanks,
Brad
|
|
|
|
|
I found it... here is the magic override...
protected override bool IsInputKey(Keys key)
{
switch (key)
{
case Keys.Up:
case Keys.Down:
case Keys.Right:
case Keys.Left:
return true;
}
return base.IsInputKey(key);
}
|
|
|
|
|
hello,
how can I use AdjustTokenPrivileges en C# ?
thanks
Vincent
|
|
|
|
|
I find this : it is ok and run correctly
public struct TOKEN_PRIVILEGES
{
public LUID Luid;
public int Attributes;
public int PrivilegeCount;
}
//Ajustement du token privilege
[DllImport("advapi32.dll", CharSet = CharSet.Auto)]
public static extern int AdjustTokenPrivileges(int tokenhandle, int disableprivs,
[MarshalAs(UnmanagedType.Struct)]ref TOKEN_PRIVILEGES Newstate, int bufferlength,
int PreivousState, int Returnlength);
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
public struct LUID
{
public int LowPart;
public int HighPart;
}
[StructLayout(LayoutKind.Sequential)]
public struct TOKEN_PRIVILEGES
{
public LUID Luid;
public int Attributes;
public int PrivilegeCount;
}
|
|
|
|
|
Hi all
How can i access a specified field's value in a crystal report by code
eg : like how can i increment a value of a specified field in a crystal report by code (in an event(Button_click))
thanks
SalehMahmoud
|
|
|
|
|
One listing is enough. We're not blind.
|
|
|
|
|