0

I am using DevExpress Components controls.I want to create controls from string Value

like "DevExpress.XtraEditors.TextEdit".I know I can make this with reflection like

var textBoxType = typeof(Control).Assembly.GetType("System.Windows.Forms.TextBox", true);
var textBox = Activator.CreateInstance(textBoxType);

I want to make this for write little code.but DevExpress have a lot of namespace and class. Can I create control from string unless give A MainClass? (like my sample code typeof(Control)) if I can not make I have to use alot of if

0

1 Answer 1

2

You need to know which assembly the class is defined in.

For example, all of the editors are in DevExpress.XtraEditors.vX.Y.dll, or typeof(BaseEdit).Assembly.

If you don't know which assembly it's defined in, you can create a collection of DevExpress assemblies (typeof(GridControl).Assembly, typeof(TreeList).Assembly, ...) and loop through them until asm.GetType(name) doesn't return null.
Note that it will be very slow.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.