Click here to Skip to main content
15,881,757 members
Home / Discussions / C#
   

C#

 
Generalprevious article on copying windows explorer functionality Pin
Anonymous25-Apr-05 9:08
Anonymous25-Apr-05 9:08 
GeneralRe: previous article on copying windows explorer functionality Pin
Polis Pilavas26-Apr-05 1:55
Polis Pilavas26-Apr-05 1:55 
QuestionSerialPort(framwork2) is freezing when closing? Pin
Snowjim25-Apr-05 8:10
Snowjim25-Apr-05 8:10 
AnswerRe: SerialPort(framwork2) is freezing when closing? Pin
Snowjim25-Apr-05 8:14
Snowjim25-Apr-05 8:14 
GeneralRe: SerialPort(framwork2) is freezing when closing? Pin
Snowjim25-Apr-05 8:36
Snowjim25-Apr-05 8:36 
GeneralSecondary message loop Pin
Luis Alonso Ramos25-Apr-05 7:48
Luis Alonso Ramos25-Apr-05 7:48 
GeneralRe: Secondary message loop Pin
S. Senthil Kumar25-Apr-05 19:06
S. Senthil Kumar25-Apr-05 19:06 
GeneralCompile differences in file and memory Pin
machocr25-Apr-05 7:15
machocr25-Apr-05 7:15 
Hi, I generate code (codigo) dinamcally and then complile it in memory for showit in propertyGrid
<br />
parametros.ReferencedAssemblies.Add("System.dll");<br />
parametros.ReferencedAssemblies.Add("System.Data.dll");<br />
parametros.ReferencedAssemblies.Add("System.Design.dll");<br />
parametros.GenerateInMemory = true;<br />
CompilerResults compilado = compilador.CompileAssemblyFromSource(parametros,codigo);<br />


The class made has inset classes of custom stringconverter for asssig enums to properyies and show in combo way.

<br />
this.Objeto = ensambaldo.CreateInstance("miNamespace.miClase",false,BindingFlags.CreateInstance,null,new object[]{this.DS.Tables[0].Rows[0]},System.Globalization.CultureInfo.CurrentCulture,null);<br />


Then I copy the code and paste to a fisical class.cs and compile the project and make an instance of myClass
I show the objects int PropertyGrid These objets

The object that made dianmically not show the combo feature in the properties but in the object made with the fisical file show the properties with the combo - enum feature, this one works fine.

What diferense can be have the two ways of make an object,D'Oh! | :doh: Confused | :confused: Cry | :(( Sniff | :^) Unsure | :~

This is the Class:
<br />
<br />
using System;<br />
using System.Data;<br />
using System.ComponentModel;<br />
using System.Reflection;<br />
<br />
namespace miNamespace <br />
{<br />
	public class miClase <br />
	{<br />
			<br />
		private System.Data.DataRow m_Row = null;<br />
		public static string[] Table1s = new string[4];<br />
		public System.Collections.Hashtable ColCustomerID = new System.Collections.Hashtable();<br />
		public System.Collections.Hashtable _ColCustomerID = new System.Collections.Hashtable();<br />
		public static string[] Table2s = new string[9];<br />
		public System.Collections.Hashtable ColEmployeeID = new System.Collections.Hashtable();<br />
		public System.Collections.Hashtable _ColEmployeeID = new System.Collections.Hashtable();<br />
		public miClase(System.Data.DataRow row)<br />
		{<br />
			m_Row = row;<br />
<br />
			Table1s[0] = "Alfreds Futterkiste";<br />
			ColCustomerID.Add("ALFKI","Alfreds Futterkiste");<br />
			_ColCustomerID.Add("Alfreds Futterkiste","ALFKI");<br />
			Table1s[1] = "Ana Trujillo Emparedados y helados";<br />
			ColCustomerID.Add("ANATR","Ana Trujillo Emparedados y helados");<br />
			_ColCustomerID.Add("Ana Trujillo Emparedados y helados","ANATR");<br />
			Table1s[2] = "Antonio Moreno Taquería";<br />
			ColCustomerID.Add("ANTON","Antonio Moreno Taquería");<br />
			_ColCustomerID.Add("Antonio Moreno Taquería","ANTON");<br />
			Table1s[3] = "Around the Horn";<br />
			ColCustomerID.Add("AROUT","Around the Horn");<br />
			_ColCustomerID.Add("Around the Horn","AROUT");<br />
<br />
			Table2s[0] = "Davolio, Nancy";<br />
			ColEmployeeID.Add("1","Davolio, Nancy");<br />
			_ColEmployeeID.Add("Davolio, Nancy","1");<br />
			Table2s[1] = "Fuller, Andrew";<br />
			ColEmployeeID.Add("2","Fuller, Andrew");<br />
			_ColEmployeeID.Add("Fuller, Andrew","2");<br />
			Table2s[2] = "Leverling, Janet";<br />
			ColEmployeeID.Add("3","Leverling, Janet");<br />
			_ColEmployeeID.Add("Leverling, Janet","3");<br />
			Table2s[3] = "Peacock, Margaret";<br />
			ColEmployeeID.Add("4","Peacock, Margaret");<br />
			_ColEmployeeID.Add("Peacock, Margaret","4");<br />
			Table2s[4] = "Buchanan, Steven";<br />
			ColEmployeeID.Add("5","Buchanan, Steven");<br />
			_ColEmployeeID.Add("Buchanan, Steven","5");<br />
			Table2s[5] = "Suyama, Michael";<br />
			ColEmployeeID.Add("6","Suyama, Michael");<br />
			_ColEmployeeID.Add("Suyama, Michael","6");<br />
			Table2s[6] = "King, Robert";<br />
			ColEmployeeID.Add("7","King, Robert");<br />
			_ColEmployeeID.Add("King, Robert","7");<br />
			Table2s[7] = "Callahan, Laura";<br />
			ColEmployeeID.Add("8","Callahan, Laura");<br />
			_ColEmployeeID.Add("Callahan, Laura","8");<br />
			Table2s[8] = "Dodsworth, Anne";<br />
			ColEmployeeID.Add("9","Dodsworth, Anne");<br />
			_ColEmployeeID.Add("Dodsworth, Anne","9");<br />
<br />
			if(row["OrderID"] != DBNull.Value)<br />
			{<br />
				this.OrderID = (System.Int32)row["OrderID"];<br />
			}<br />
			if(row["CustomerID"] != DBNull.Value)<br />
			{<br />
				if(ColCustomerID[row["CustomerID"]] != null)<br />
				{<br />
					this.CompanyName = (string)ColCustomerID[row["CustomerID"]];<br />
				}<br />
			}<br />
			if(row["EmployeeID"] != DBNull.Value)<br />
			{<br />
				if(ColEmployeeID[row["EmployeeID"]] != null)<br />
				{<br />
					this.Name = (string)ColEmployeeID[row["EmployeeID"]];<br />
				}<br />
			}<br />
			if(row["OrderDate"] != DBNull.Value)<br />
			{<br />
				this.OrderDate = (System.DateTime)row["OrderDate"];<br />
			}<br />
			if(row["RequiredDate"] != DBNull.Value)<br />
			{<br />
				this.RequiredDate = (System.DateTime)row["RequiredDate"];<br />
			}<br />
			if(row["ShippedDate"] != DBNull.Value)<br />
			{<br />
				this.ShippedDate = (System.DateTime)row["ShippedDate"];<br />
			}<br />
			if(row["ShipVia"] != DBNull.Value)<br />
			{<br />
				this.ShipVia = (System.Int32)row["ShipVia"];<br />
			}<br />
			if(row["Freight"] != DBNull.Value)<br />
			{<br />
				this.Freight = (System.Decimal)row["Freight"];<br />
			}<br />
			if(row["ShipName"] != DBNull.Value)<br />
			{<br />
				this.ShipName = (System.String)row["ShipName"];<br />
			}<br />
			if(row["ShipAddress"] != DBNull.Value)<br />
			{<br />
				this.ShipAddress = (System.String)row["ShipAddress"];<br />
			}<br />
			if(row["ShipCity"] != DBNull.Value)<br />
			{<br />
				this.ShipCity = (System.String)row["ShipCity"];<br />
			}<br />
			if(row["ShipRegion"] != DBNull.Value)<br />
			{<br />
				this.ShipRegion = (System.String)row["ShipRegion"];<br />
			}<br />
			if(row["ShipPostalCode"] != DBNull.Value)<br />
			{<br />
				this.ShipPostalCode = (System.String)row["ShipPostalCode"];<br />
			}<br />
			if(row["ShipCountry"] != DBNull.Value)<br />
			{<br />
				this.ShipCountry = (System.String)row["ShipCountry"];<br />
			}<br />
		}<br />
		private System.Int32 m_OrderID;<br />
<br />
		public System.Int32 OrderID<br />
		{<br />
			get { return m_OrderID; }<br />
			set <br />
			{ <br />
				m_OrderID = value;m_Row["OrderID"] = value;<br />
			}<br />
		}<br />
<br />
		private string m_CompanyName;<br />
		[Browsable(true)][TypeConverter(typeof(Table1Converter))]<br />
		public string CompanyName<br />
		{<br />
			get { return m_CompanyName; }<br />
			set <br />
			{ <br />
				m_CompanyName = value;m_Row["CustomerID"] = _ColCustomerID[value];<br />
			}<br />
		}<br />
<br />
		private string m_Name;<br />
		[Browsable(true)][TypeConverter(typeof(Table2Converter))]<br />
		public string Name<br />
		{<br />
			get { return m_Name; }<br />
			set <br />
			{ <br />
				m_Name = value;m_Row["EmployeeID"] = _ColEmployeeID[value];<br />
			}<br />
		}<br />
<br />
		private System.DateTime m_OrderDate;<br />
<br />
		public System.DateTime OrderDate<br />
		{<br />
			get { return m_OrderDate; }<br />
			set <br />
			{ <br />
				m_OrderDate = value;m_Row["OrderDate"] = value;<br />
			}<br />
		}<br />
<br />
		private System.DateTime m_RequiredDate;<br />
<br />
		public System.DateTime RequiredDate<br />
		{<br />
			get { return m_RequiredDate; }<br />
			set <br />
			{ <br />
				m_RequiredDate = value;m_Row["RequiredDate"] = value;<br />
			}<br />
		}<br />
<br />
		private System.DateTime m_ShippedDate;<br />
<br />
		public System.DateTime ShippedDate<br />
		{<br />
			get { return m_ShippedDate; }<br />
			set <br />
			{ <br />
				m_ShippedDate = value;m_Row["ShippedDate"] = value;<br />
			}<br />
		}<br />
<br />
		private System.Int32 m_ShipVia;<br />
<br />
		public System.Int32 ShipVia<br />
		{<br />
			get { return m_ShipVia; }<br />
			set <br />
			{ <br />
				m_ShipVia = value;m_Row["ShipVia"] = value;<br />
			}<br />
		}<br />
<br />
		private System.Decimal m_Freight;<br />
<br />
		public System.Decimal Freight<br />
		{<br />
			get { return m_Freight; }<br />
			set <br />
			{ <br />
				m_Freight = value;m_Row["Freight"] = value;<br />
			}<br />
		}<br />
<br />
		private System.String m_ShipName;<br />
<br />
		public System.String ShipName<br />
		{<br />
			get { return m_ShipName; }<br />
			set <br />
			{ <br />
				m_ShipName = value;m_Row["ShipName"] = value;<br />
			}<br />
		}<br />
<br />
		private System.String m_ShipAddress;<br />
<br />
		public System.String ShipAddress<br />
		{<br />
			get { return m_ShipAddress; }<br />
			set <br />
			{ <br />
				m_ShipAddress = value;m_Row["ShipAddress"] = value;<br />
			}<br />
		}<br />
<br />
		private System.String m_ShipCity;<br />
<br />
		public System.String ShipCity<br />
		{<br />
			get { return m_ShipCity; }<br />
			set <br />
			{ <br />
				m_ShipCity = value;m_Row["ShipCity"] = value;<br />
			}<br />
		}<br />
<br />
		private System.String m_ShipRegion;<br />
<br />
		public System.String ShipRegion<br />
		{<br />
			get { return m_ShipRegion; }<br />
			set <br />
			{ <br />
				m_ShipRegion = value;m_Row["ShipRegion"] = value;<br />
			}<br />
		}<br />
<br />
		private System.String m_ShipPostalCode;<br />
<br />
		public System.String ShipPostalCode<br />
		{<br />
			get { return m_ShipPostalCode; }<br />
			set <br />
			{ <br />
				m_ShipPostalCode = value;m_Row["ShipPostalCode"] = value;<br />
			}<br />
		}<br />
<br />
		private System.String m_ShipCountry;<br />
<br />
		public System.String ShipCountry<br />
		{<br />
			get { return m_ShipCountry; }<br />
			set <br />
			{ <br />
				m_ShipCountry = value;m_Row["ShipCountry"] = value;<br />
			}<br />
		}<br />
<br />
	<br />
		public class Table1Converter : StringConverter<br />
		{<br />
<br />
			public override bool GetStandardValuesSupported(ITypeDescriptorContext context)<br />
			{<br />
				return true;<br />
			}<br />
<br />
			public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)<br />
			{<br />
				return true;<br />
			}<br />
<br />
			public override<br />
				System.ComponentModel.TypeConverter.StandardValuesCollection<br />
				GetStandardValues(ITypeDescriptorContext context)<br />
			{<br />
				return new StandardValuesCollection(Table1s);<br />
			}<br />
<br />
		}<br />
<br />
		public class Table2Converter : StringConverter<br />
		{<br />
<br />
			public override bool GetStandardValuesSupported(ITypeDescriptorContext context)<br />
			{<br />
				return true;<br />
			}<br />
<br />
			public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)<br />
			{<br />
				return true;<br />
			}<br />
<br />
			public override<br />
				System.ComponentModel.TypeConverter.StandardValuesCollection<br />
				GetStandardValues(ITypeDescriptorContext context)<br />
			{<br />
				return new StandardValuesCollection(Table2s);<br />
			}<br />
<br />
		}<br />
	}}<br />


La realidad no es más que impulsos eléctricos del cerebro - Morpheus
GeneralHello All -- Some Problem In C# Pin
OMSSD8425-Apr-05 6:43
OMSSD8425-Apr-05 6:43 
GeneralRe: Hello All -- Some Problem In C# Pin
Polis Pilavas25-Apr-05 8:46
Polis Pilavas25-Apr-05 8:46 
GeneralRe: Hello All -- Some Problem In C# Pin
OMSSD8425-Apr-05 20:01
OMSSD8425-Apr-05 20:01 
GeneralRe: Hello All -- Some Problem In C# Pin
Polis Pilavas26-Apr-05 1:32
Polis Pilavas26-Apr-05 1:32 
GeneralHide the command window Pin
Sheela Krishnan25-Apr-05 6:15
Sheela Krishnan25-Apr-05 6:15 
GeneralRe: Hide the command window Pin
Steven Campbell25-Apr-05 6:24
Steven Campbell25-Apr-05 6:24 
GeneralRe: Hide the command window Pin
Dave Kreskowiak25-Apr-05 8:25
mveDave Kreskowiak25-Apr-05 8:25 
GeneralRe: Hide the command window Pin
Sheela Krishnan25-Apr-05 11:20
Sheela Krishnan25-Apr-05 11:20 
GeneralAbout Resource File Pin
SAMURAI-MAN25-Apr-05 5:35
SAMURAI-MAN25-Apr-05 5:35 
GeneralOpening a specified folder; double-clickon system tray icon Pin
Anonymous25-Apr-05 5:33
Anonymous25-Apr-05 5:33 
GeneralRe: Opening a specified folder; double-clickon system tray icon Pin
Polis Pilavas25-Apr-05 8:53
Polis Pilavas25-Apr-05 8:53 
GeneralRe: Opening a specified folder; double-clickon system tray icon Pin
mav.northwind25-Apr-05 20:24
mav.northwind25-Apr-05 20:24 
GeneralExport generated data to database. Pin
StoneWolfSoft25-Apr-05 5:22
StoneWolfSoft25-Apr-05 5:22 
GeneralObject reference not set to an instance of an object. On Marshal.PtrToStructure Method Pin
mrxero25-Apr-05 4:44
mrxero25-Apr-05 4:44 
GeneralSaving socket connection information Pin
CheckDude25-Apr-05 4:27
CheckDude25-Apr-05 4:27 
GeneralRe: Saving socket connection information Pin
S. Senthil Kumar26-Apr-05 2:31
S. Senthil Kumar26-Apr-05 2:31 
GeneralRe: Saving socket connection information Pin
CheckDude10-May-05 5:59
CheckDude10-May-05 5:59 

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.