Click here to Skip to main content
15,893,266 members
Home / Discussions / C#
   

C#

 
GeneralRe: Wonder of DataGrid imort from Excel file Pin
Libra27-Jan-06 16:21
Libra27-Jan-06 16:21 
QuestionRead and Replace Pin
picasso226-Jan-06 12:29
picasso226-Jan-06 12:29 
AnswerRe: Read and Replace Pin
Ravi Bhavnani26-Jan-06 12:42
professionalRavi Bhavnani26-Jan-06 12:42 
AnswerRe: Read and Replace Pin
DigitalKing26-Jan-06 14:30
DigitalKing26-Jan-06 14:30 
QuestionDisplay live video from an ethernet camera Pin
greg ross26-Jan-06 12:08
greg ross26-Jan-06 12:08 
AnswerRe: Display live video from an ethernet camera Pin
Daniel Santillanes26-Jan-06 13:00
professionalDaniel Santillanes26-Jan-06 13:00 
GeneralRe: Display live video from an ethernet camera Pin
greg ross31-Jan-06 3:18
greg ross31-Jan-06 3:18 
QuestionFun with generics Pin
tantiboh26-Jan-06 12:07
tantiboh26-Jan-06 12:07 
Here's a good problem.

I'm trying to set up a system where text fields in a database define dynamically-generated controls on the form. In other words, when a user makes a selection on the form, the system will pull all the records that match that selection from a database that contains text information that defines all the controls from one table, and text information that defines each of those controls' properties from a related table.

Now, I could set up switch statements that would satisfy many of the possible permutations. But that would require hundreds of lines of code, and it wouldn't be feasible to predict all the possibilities.

My idea is to use generics (which I'm just learning about) to dynamically define the controls and their properties. In essense, I need to somehow get text from the database into the utilization of the generic.

Conceptually, something along these lines:

****

public class GenericControl<T>
{
**Code to construct the control**
}

class TestGeneric
{
private void BuildControl()
{
//In reality, this string would be retrieved from the database.
string controltype = "System.Web.UI.WebControls.TextBox";

//Then the part that won't work:
GenericControl<controltype> MyControl = new GenericControl<controltype>();
}
}

****

Now, if I understand correctly, generic utilization requires that you use a defined object where I have "controltype" - which is why the above example won't work. Is there any way to take the string "System.Web.UI.WebControls.TextBox" and use it to get a TextBox object type (or the appropriate object type) - without using a switch statement?
AnswerRe: Fun with generics Pin
Guffa26-Jan-06 12:27
Guffa26-Jan-06 12:27 
AnswerRe: Fun with generics Pin
Le centriste27-Jan-06 1:38
Le centriste27-Jan-06 1:38 
QuestionWindows refresh Pin
Kwai Cheng Kane26-Jan-06 9:43
Kwai Cheng Kane26-Jan-06 9:43 
AnswerRe: Windows refresh Pin
James Gupta26-Jan-06 10:21
professionalJames Gupta26-Jan-06 10:21 
GeneralRe: Windows refresh Pin
Kwai Cheng Kane26-Jan-06 10:28
Kwai Cheng Kane26-Jan-06 10:28 
GeneralRe: Windows refresh Pin
James Gupta26-Jan-06 10:58
professionalJames Gupta26-Jan-06 10:58 
Questionsystem tray Pin
mehrdadc4826-Jan-06 9:36
mehrdadc4826-Jan-06 9:36 
AnswerRe: system tray Pin
André Ziegler26-Jan-06 10:02
André Ziegler26-Jan-06 10:02 
AnswerRe: system tray Pin
Ravi Bhavnani26-Jan-06 10:20
professionalRavi Bhavnani26-Jan-06 10:20 
QuestionStrings and Interop Pin
Beringer26-Jan-06 9:27
Beringer26-Jan-06 9:27 
AnswerRe: Strings and Interop Pin
Beringer26-Jan-06 9:50
Beringer26-Jan-06 9:50 
GeneralRe: Strings and Interop Pin
Andy Moore26-Jan-06 11:17
Andy Moore26-Jan-06 11:17 
GeneralRe: Strings and Interop Pin
Beringer26-Jan-06 17:52
Beringer26-Jan-06 17:52 
AnswerRe: Strings and Interop Pin
James Gupta26-Jan-06 10:59
professionalJames Gupta26-Jan-06 10:59 
AnswerRe: Strings and Interop Pin
DigitalKing26-Jan-06 14:36
DigitalKing26-Jan-06 14:36 
GeneralRe: Strings and Interop Pin
Beringer26-Jan-06 15:27
Beringer26-Jan-06 15:27 
QuestionHelp with Code conversion Pin
TMF32026-Jan-06 7:11
TMF32026-Jan-06 7:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.