Click here to Skip to main content
15,915,160 members
Home / Discussions / C#
   

C#

 
GeneralRe: monitor Pin
fmardani26-Jan-06 23:30
fmardani26-Jan-06 23:30 
QuestionHow to play stream on windows media player? Pin
Divyang Mithaiwala26-Jan-06 20:46
Divyang Mithaiwala26-Jan-06 20:46 
Questionhow to open a pdf File Pin
Venkatram.S26-Jan-06 19:57
Venkatram.S26-Jan-06 19:57 
AnswerRe: how to open a pdf File Pin
Guffa26-Jan-06 21:09
Guffa26-Jan-06 21:09 
GeneralRe: how to open a pdf File Pin
Venkatram.S26-Jan-06 21:30
Venkatram.S26-Jan-06 21:30 
GeneralRe: how to open a pdf File Pin
Kodanda Pani26-Jan-06 22:52
Kodanda Pani26-Jan-06 22:52 
AnswerRe: how to open a pdf File Pin
Arne Kuehn26-Jan-06 23:20
Arne Kuehn26-Jan-06 23:20 
QuestionShow Window Pin
jzb26-Jan-06 18:57
jzb26-Jan-06 18:57 
AnswerRe: Show Window Pin
James Gupta26-Jan-06 21:02
professionalJames Gupta26-Jan-06 21:02 
GeneralRe: Show Window Pin
jzb26-Jan-06 21:46
jzb26-Jan-06 21:46 
QuestionXML Serialization Pin
LighthouseJ26-Jan-06 18:40
LighthouseJ26-Jan-06 18:40 
AnswerRe: XML Serialization Pin
leppie26-Jan-06 21:30
leppie26-Jan-06 21:30 
GeneralRe: XML Serialization Pin
LighthouseJ27-Jan-06 5:41
LighthouseJ27-Jan-06 5:41 
QuestionWonder of DataGrid imort from Excel file Pin
Libra26-Jan-06 15:43
Libra26-Jan-06 15:43 
AnswerRe: Wonder of DataGrid imort from Excel file Pin
Kodanda Pani26-Jan-06 20:36
Kodanda Pani26-Jan-06 20:36 
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 

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.