Visual C# General ForumGeneral discussion and questions regarding Visual C# -- including best practices on developing with C# in VS, documentation, setup, and samples.© 2009 Microsoft Corporation. All rights reserved.Wed, 25 Nov 2009 23:38:00 Z24becc9b-b984-47b2-a748-a62e38c0066fhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/82c952b7-9524-4dec-a30e-f068e9b27859http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/82c952b7-9524-4dec-a30e-f068e9b27859JennyXYZhttp://social.msdn.microsoft.com/Profile/en-US/?user=JennyXYZRead XML to DataSetHi I have a little problem.<br/> <br/> I have a XML file which holds information for about of 100 students with little info(Name, Year). I need to read that XML file and to draw a table which will show how many students is there on each year. How can I do that?<br/> <br/> Thank you for any help :)Wed, 25 Nov 2009 22:04:16 Z2009-11-25T23:37:59Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/c23ae03f-df8c-45f7-ac0f-e001e71cc6f5http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/c23ae03f-df8c-45f7-ac0f-e001e71cc6f5CommanderKeenhttp://social.msdn.microsoft.com/Profile/en-US/?user=CommanderKeenTest string for \n or \t<p>Hello I am wondering how I can test if there is a \n or a \t in a string.</p> <p>string tmpString = &quot;asdf \n asdf&quot;;</p> <p>Thanks for your time.</p>Wed, 25 Nov 2009 20:25:32 Z2009-11-25T23:27:31Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/a5f09794-3224-4c9d-8453-688a303a9198http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/a5f09794-3224-4c9d-8453-688a303a9198Ling Ninahttp://social.msdn.microsoft.com/Profile/en-US/?user=Ling%20Ninacall javascript function from C# code-behind <p>Hi all, <br/><br/>in my C# code behind, page_load , I wrote the following code: <br/><br/>String jScript;<br/>jScript=&quot;&lt;script language='javascript'&gt; function changeBgColor()&quot; + <br/>           &quot; {  var td = document.getElementById('&quot; + td + &quot;'); \n&quot;; <br/>jScript+=&quot;if (!td) throw 'td not found'; \n &quot;;<br/>jScript += &quot;td.Class='calendaritemtd-Weekend';  \n&quot;;<br/>jScript+=&quot; } &lt;/script&gt;&quot;;</p> <p>Page.ClientScript.RegisterStartupScript(this.GetType(), &quot;changeColor&quot;, jScript);   <br/><br/>I also tried <br/>   Page.RegisterStartupScript(&quot;changeColor&quot;, jScript)<br/>   Page.RegisterClientScriptBlock(&quot;changeColor&quot;, jScript)<br/><br/>but none of these works. <br/>I even tried to test the jScript string content via LabelTest.Text = jScript, but could not retrieve anything from LabelTest.Text. <br/><br/>could anybody help? <br/><br/>another question: if I want to insert Javascript in html file, but I am currently using site.Master, should I write code in site.Master, between &lt;head&gt; and &lt;/head&gt;? <br/><br/>Thank you, <br/><br/>Ling</p>Wed, 25 Nov 2009 12:25:15 Z2009-11-25T22:53:14Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5290573b-e4d8-4451-b6af-426f3098b68fhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5290573b-e4d8-4451-b6af-426f3098b68fprogramatichttp://social.msdn.microsoft.com/Profile/en-US/?user=programaticRunning into another problem with FileSystemWatcher.cs?Was using this library class for my last application (and it worked) but recently been testing my last application and found out a new problem.. :(<br/> <br/> It detects auto-created files by processes.<br/> Is there a way to stop or another way round to prevent it from detecting auto-created files by processes?<br/> <br/> I keep getting events firing for files created/renamed etc.. within the applicationData folders. <br/> <br/> Some are .lnk/.tmp files. Others are images files from third party software which it doesnt use the standard AppData folder -  uses its own folders which its a huge problem because if not - i can easily check whether the file resides in appData. I couldnt possibly have a list of all programs appData folders..<br/> <br/> help.. lolTue, 24 Nov 2009 21:58:32 Z2009-11-25T22:47:21Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/edea79fe-af15-4b5a-ab07-845a2e0c3a56http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/edea79fe-af15-4b5a-ab07-845a2e0c3a56aruizmoraleshttp://social.msdn.microsoft.com/Profile/en-US/?user=aruizmoralesCheck for Open ApplicationHello,<br/><br/>I'm working on a project that needs to verify if a win32 application is opened. If it is not opened then I will use Process.Start(appplication path) to open it. <br/><br/>Does anyone know what class to use to verify if an application is open or not ?Wed, 25 Nov 2009 18:36:39 Z2009-11-25T21:57:22Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/32ac0ca0-ad81-4a8c-97ec-1d1a92b3f405http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/32ac0ca0-ad81-4a8c-97ec-1d1a92b3f405Gurunethttp://social.msdn.microsoft.com/Profile/en-US/?user=GurunetDatagridview and TabControlHi, On my windows form, I have a tabcontrol with 5 tabs and 4 tabs has a datagridview. I have a menu strip which has a new menu. When the user click on the new menu, some text boxes in the first tab will be filled out with some data and the user will finish inputing data in other textboxes. When I execute the program, all the datagridview shows fine with the correct data. But when i  click the new button, it shows the first tab with some textboxes filled out(as programmed) and my last datagridview filled out with another table data &gt;&gt; I don't know why here is the code snippet:<br/> <br/> private void Form1_Load(object sender, EventArgs e)<br/>         {<br/>             DGVOpen.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);<br/>             GetData(&quot;Select Ticket_Num,Request_By,Assigned_To,Problem,Solution,Date_Open, Checkbox from Main where Status = 'Open' Order By Ticket_Num&quot;);<br/>             DGVOpen.DataSource = BS1;<br/>             DGVClosed.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);<br/>             BS1 = new BindingSource();<br/>             GetData(&quot;Select Ticket_Num,Request_By,Assigned_To,Problem,Solution,Date_Closed, Checkbox from Main where Status = 'Closed' Order By Ticket_Num&quot;);<br/>             DGVClosed.DataSource = BS1;<br/>             DGVUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);<br/>             BS1 = new BindingSource();<br/>             GetData(&quot;Select * from Users&quot;);<br/>             DGVUser.DataSource = BS1;<br/>             DGVVendor.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);<br/>             BS1 = new BindingSource();<br/>             GetData(&quot;Select * from Vendor&quot;);<br/>             DGVVendor.DataSource = BS1;<br/>         }<br/>         private void GetData(string SelectCommand)<br/>         {<br/>             try<br/>             {<br/>                 oconn = new OleDbConnection(@&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\HelpDesk.mdb&quot;);<br/>                 DA = new OleDbDataAdapter(SelectCommand, oconn);<br/>                 OleDbCommandBuilder Ocommand = new OleDbCommandBuilder(DA);<br/>                 DT = new DataTable();<br/>                 DS = new DataSet();<br/>                 DT.Locale = System.Globalization.CultureInfo.InvariantCulture;<br/>                 DA.Fill(DT);<br/>                 DA.Fill(DS);<br/>                 BS1.DataSource = DT;<br/>             }<br/>             catch (Exception ex)<br/>             {<br/>                 MessageBox.Show(ex.Message);<br/>             }<br/> <br/>         }<br/> <br/> private void newTicketToolStripMenuItem_Click(object sender, EventArgs e)<br/>         {<br/>             if (tabControl1.SelectedTab != tbTicket)<br/>             {<br/>                 this.tabControl1.SelectedTab = tbTicket;<br/>                 tbTicket.Show();<br/>             }<br/>             DisplayBlank();<br/>             displayvendorcombobox();<br/>             GetData(&quot;Select * from Main&quot;);<br/>             int i = DT.Rows.Count;<br/>             int month = DateTime.Now.Month;<br/>             int year = DateTime.Now.Year;<br/>             TxtTicket.Text = &quot;AIB&quot; + month + year + &quot;-&quot; + i;<br/>             TxtStatus.Text = &quot;Open&quot;;<br/>         }Wed, 25 Nov 2009 19:11:38 Z2009-11-25T21:56:51Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/002ab756-6825-42f1-a8a7-86cebd3e5b1dhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/002ab756-6825-42f1-a8a7-86cebd3e5b1dOdomaeBhttp://social.msdn.microsoft.com/Profile/en-US/?user=OdomaeBEnumerating USB device with multiple logical unitsHi,<br/> <br/>  I have a USB device that has 2 logical units. <br/> USBSTOR\DISK&amp;VEN_XXXX&amp;PROD_YYYY&amp;REV_0100\0123456789990&amp;0 (Drive A:) <br/> <br/> USBSTOR\DISK&amp;VEN_XXXX&amp;PROD_YYYY&amp;REV_0100\0123456789990&amp;1 (Drive B:) <br/> <br/> I used SetupDiEnumDeviceInterfaces() func and I get just one:USBSTOR\DISK&amp;VEN_XXXX&amp;PROD_YYYY&amp;REV_0100\0123456789990 <br/> <br/> I guess this is understandable since there is only one physical device. However, is there a function that I can use to get both the drive letters? <br/> <br/> I used the DEVINTERFACE_VOLUME GUID for the SetupDiEnumDeviceInterfaces() function.<br/>Wed, 25 Nov 2009 21:51:16 Z2009-11-25T21:51:17Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/7f10aedf-d360-459d-8e08-3b6ba05b5d6bhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/7f10aedf-d360-459d-8e08-3b6ba05b5d6bRoxxorhttp://social.msdn.microsoft.com/Profile/en-US/?user=RoxxorSystem.Configuration.Install does not exist, why?Hi, <br/> I am trying to install a Windows Service and I have followed the guide on <a title="http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.aspx" href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.aspx" title="http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.aspx">http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.aspx</a> .<br/> But my compiler cannot find the class System.Configuration.Install. <br/> The only class under System.Configuration is &quot;Assemblies&quot;. Where is the &quot;Install&quot; class?<br/>Wed, 25 Nov 2009 19:52:47 Z2009-11-25T21:21:01Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/6b4b000b-543b-4d70-abc2-c6684ee76fdchttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/6b4b000b-543b-4d70-abc2-c6684ee76fdcCommanderKeenhttp://social.msdn.microsoft.com/Profile/en-US/?user=CommanderKeenChallenging RichTextBox Sizing problem.I have a challenging RIchTextBox Sizing problem.<br/><br/>The problem is as follows:<br/><br/>You are given a string of arbitrary length. <br/><br/>The RichTextBox must size it's width so that the string is not broken into another line (no scroll bars on the richtextbox).<br/>(example: By nature of the RTB itself if a string is of width = 600 but the RTB is only width = 100 then scroll bars will appear and the string will be broken in several lines).<br/><br/>If the string is longer than some MaxWidth (Lets make MaxWidth = 800), then the string must be broken into two lines at length 800 and then the richtextbox must increase it's height so that it can show the string without the scroll bars.<br/><br/>(example: if string is of length 1000 and the hieght of the string is 13 then the string will be broken up: one line will be 800 width and another line will be 400 width the total hieght of the new RTB is now 13*2 = 26.<br/><br/>To further complicate things (and this is what makes the problem difficult) this string can have an arbitrary amount of \t or \n tags in it.<br/><br/>To summarize these conditions: <br/><br/>The RTB can make NO predictions on the contents of the string it's going to accept to it's .text property (must allow for all legal strings).<br/><br/>The RTB must have no scroll bars.<br/>The RTB must never be more wide than MaxWidth (800);<br/>The RTB must not be un-neccessarily tall.  (there should not be blank RTB space under the last line).<br/><br/>To get started I have this code: <br/><br/> <pre lang="x-c#">RichTextBox messageLabel = new RichTextBox(); string str = messageForm.MessageLabel.Text; Size strSize = TextRenderer.MeasureText(str, messageForm.MessageLabel.Font); messageLabel.Width = strSize.Width messageLabel.SelectionAlignment = HorizontalAlignment.Center; int numberOfTextLines; // if string has no \n or \t if (messageForm.MessageLabel.Width &gt; BusinessRule.MaxWidth) { // if string is too long break up into lines of MAX width messageForm.MessageLabel.Width = BusinessRule.MaxWidth; numberOfTextLines = messageForm.MessageLabel.GetLineFromCharIndex(messageForm.MessageLabel.Text.Length) + 1; messageForm.MessageLabel.Height = numberOfTextLines * strSize.Height; } else { numberOfTextLines = messageForm.MessageLabel.Lines.Length; messageForm.MessageLabel.Height = strSize.Height; } messageForm.MessageLabel.BackColor = Color.Red; if (numberOfTextLines &gt; 1) { messageForm.MessageLabel.SelectionAlignment = HorizontalAlignment.Left; }</pre> This code actually works for all instances except for when I pass it the string: <br/><br/><span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="font-size:x-small;color:#a31515"><span style="font-size:x-small;color:#a31515">&quot;contactClass: Postal Code is invalid.\n But the invalid is not valid. \n\n Nor Should it ever be that way, yes?&quot;</span></span></p>Wed, 25 Nov 2009 20:45:03 Z2009-11-25T20:45:04Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d435f705-17af-48b2-8838-be5da13087b4http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d435f705-17af-48b2-8838-be5da13087b4Mitja Boncahttp://social.msdn.microsoft.com/Profile/en-US/?user=Mitja%20BoncaProblem with local variable (collection)For my test application I am doing now a collection of books, and I already did a filter.  <div>But when I want to do a collection, and use the variable, the is no variable. You can see from the drop down manu that there is no &quot;filter&quot; name, as I named the collection. Why is that so?</div> <div><br/><img src="http://www.file.si/files/plkgab3qvh9dejuvt3b9.jpg" alt=""></div>Wed, 25 Nov 2009 19:55:07 Z2009-11-25T20:15:26Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/e1112ff8-aaae-4d26-a042-795c017f609ehttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/e1112ff8-aaae-4d26-a042-795c017f609eE_goldhttp://social.msdn.microsoft.com/Profile/en-US/?user=E_goldProblem with .xsd file - refreshhi<br/>i build C# program that connect to access database.<br/>i have .xsd file that connect to database - and through this .xsd  i connect to crystal-report.<br/>this all work excellent.<br/>now, i added 2 query in the database - and the problen that i can't see them in the .xsd file<br/><br/>whay ?<br/>Wed, 25 Nov 2009 20:02:59 Z2009-11-25T20:03:00Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/df8f1bd5-6d8d-4ccc-9c07-822210a7c943http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/df8f1bd5-6d8d-4ccc-9c07-822210a7c943NuNn DaDdYhttp://social.msdn.microsoft.com/Profile/en-US/?user=NuNn%20DaDdYDoes Application.Exit() Affect Form_Closing() Events<p>When the user chooses to close the application I call Application.Exit().  Within my Form_Closing code I then have the following statement to update my db with the values that have changed in the DataGridView that I present to the user.  For some reason though, unless I have at least one row selected, these changes will not be updated.  Why is this?</p>Tue, 24 Nov 2009 18:05:54 Z2009-11-25T19:56:47Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/8a27844c-a32a-4e71-a073-be1ef0829589http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/8a27844c-a32a-4e71-a073-be1ef0829589hazzhttp://social.msdn.microsoft.com/Profile/en-US/?user=hazzquestions about purpose/functionality ManualResetEvents in my socket code.Evaluating JUST the ManualResetEvents, as I am only beginning to understand them:<br/> 1. <strong>ConnectDone.Reset()</strong>   - <strong>the doors are closed</strong>, (non-signaled)  but what does that mean?  Which door is closed?  Some connect thread?<br/> 2.  <strong>ConnectDone.WaitOne()</strong> - the connect process commences. <br/> 3.  <strong>ConnectDone.Set()</strong>         -  <strong>the door is open</strong> now.  Does that mean THE thread used for the connect process is available again.  Was this a thread taken from some threadpool temporarily?<br/> 4  sendDone.Set()        -   the door is open.  <br/><br/>What I see in my code is I have no <strong>sendDone.Reset()</strong> nor do I have <strong>sendDone.WaitOne()<br/></strong>Also, I  have absolutely <strong>no ManualResetEvent</strong> variables/flags/<strong>signals</strong> in my code anywhere for <strong>Receive()</strong> and <strong>ReceiveCallBack();</strong>  <br/>As you can see, I don't know what I'm doing (but I do want to learn !!)  Thank you for any help.  greg<br/><br/> <div style="color:black;background-color:white"> <pre> <span style="color:blue">private</span> <span style="color:blue">static</span> ManualResetEvent connectDone = <span style="color:blue">new</span> ManualResetEvent(<span style="color:blue">false</span>); <span style="color:green">//??</span> <span style="color:blue">private</span> <span style="color:blue">static</span> ManualResetEvent receiveDone = <span style="color:blue">new</span> ManualResetEvent(<span style="color:blue">false</span>); <span style="color:green">//??</span> <span style="color:blue">private</span> <span style="color:blue">static</span> ManualResetEvent sendDone = <span style="color:blue">new</span> ManualResetEvent(<span style="color:blue">false</span>); <span style="color:green">//??</span> <span style="color:blue">public</span> <span style="color:blue">static</span> <span style="color:blue">void</span> BeginConnect(<span style="color:blue">string</span> host, <span style="color:blue">int</span> port) { connectDone.Reset(); connectDone.WaitOne(); } <span style="color:blue">public</span> <span style="color:blue">static</span> <span style="color:blue">void</span> ConnectCallback(IAsyncResult ar) { connectDone.Set(); } <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">void</span> SendCallback(IAsyncResult ar) { sendDone.Set(); } <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">void</span> ReceiveCallback(IAsyncResult ar) {<br/>} </pre> </div>Wed, 25 Nov 2009 15:31:23 Z2009-11-25T19:56:33Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/8508148b-9d30-4d7b-b5b4-20af94d28c21http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/8508148b-9d30-4d7b-b5b4-20af94d28c21AMcMillanhttp://social.msdn.microsoft.com/Profile/en-US/?user=AMcMillanHow do I Late Bind Reference DLLI am Referencing the Microsoft.Office.Interop.Outlook dll, but I only use it in certain situations.  If they do not have Outlook, it is not a problem for my program (because I will not use Outlook to do anything), but the app will not run because this dll is not installed.  I can't install the Office PIA because Office is not installed.  So how do I use the Outlook Interop in a &quot;late binding&quot; type of scheme where I would only call it if I knew Outlook was installed?Fri, 10 Jul 2009 15:23:54 Z2009-11-25T19:47:10Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/aa21a068-43a3-4306-b218-d95b23da76fchttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/aa21a068-43a3-4306-b218-d95b23da76fcinvader7http://social.msdn.microsoft.com/Profile/en-US/?user=invader7Dir list box...Hello every body, i have a dir list box in my form and i give it as path a network path, when i run the form it lists me the contents of the path correctly. i want to know if i can hide from dir list box the base path or if i can rename it, i don't want to see \\server\share i want to see the work &quot;base path&quot; for example !Wed, 25 Nov 2009 18:04:43 Z2009-11-25T19:35:11Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d0528b07-de80-41a2-835d-55562158773ehttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d0528b07-de80-41a2-835d-55562158773eMconwayhttp://social.msdn.microsoft.com/Profile/en-US/?user=MconwayCreating a Shortcut using WshShellClass in C#Hopefully this is a very simple solution..<br/> <br/> I am trying to create a function that generates a shortcut to the desktop, and it works.. However.. the path I am trying to use causes the shortcut creator to throw an exception..<br/> <br/> <pre lang="x-c#"> WshShellClass wshShell = new WshShellClass(); IWshRuntimeLibrary.IWshShortcut shortcut; shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(@Environment.GetEnvironmentVariable(&quot;USERPROFILE&quot;) + &quot;\\Desktop\\QPS_Punch_Clock.lnk&quot;); shortcut.TargetPath = &quot;C:\\Program Files\\Internet Explorer\\iexplore.exe -k &quot;+Properties.Settings.Default.URL; shortcut.Save();<br/> </pre> The error I am getting is very generic: Value does not fall within the expected range.<br/> <br/> The TargetPath is the culprit, I am unsure how to proceed. I am trying to generate shortcuts that open IE and Kiosk mode.. with whatever URL was specified. If I remove the Properties.Settings.Default.URL concatenation from the Target Path.. the shortcut is created but is a broken link.. because it is set to <pre lang="x-c#">&quot;C:\Program Files\Internet Explorer\iexplore.exe -k &quot;</pre> <br/> I can also make a working shortcut using only the URL Property, but it obviously is not opening in kiosk mode..<br/> <br/> Does anyone have any ideas?<br/> <br/> Thanks!<br/>Wed, 25 Nov 2009 18:41:06 Z2009-11-25T18:41:07Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/1369ff2c-3d66-4efe-bf5e-f738b13df252http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/1369ff2c-3d66-4efe-bf5e-f738b13df252MrGreenehttp://social.msdn.microsoft.com/Profile/en-US/?user=MrGreeneIs C# and WPF a good choice?<span style="font-family:verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;font-size:12px;color:#444444;line-height:20px">Dear forum members,<br/><br/>I'm working on an accounting software, which I was planing to do using C#. Now that I see there is WPF that I can use instead of WinForms, I would like to ask you a couple of questions.<br/><ol style="list-style-type:decimal"> <li style="margin-bottom:5px">For an account software, which I would like to have it looking good, with dynamic graphs and &quot;easy on eyes&quot; with light animations (like apps on iphone, transitions etc), is C# .NET WPF a good choice? What would be your recommendations?</li> <li style="margin-bottom:5px">And how can I skin the window completely? Like, iTunes working on a Windows machine. The window and the title bar is custom, but buttons for quitting the application or minimizing it still the Windows one. How can I do this with VS and C# with WPF?</li> <li style="margin-bottom:5px">Once the project is complete, can I deploy it to work on a web browser? Is it possible? Because I read some stuff like this.</li> <li style="margin-bottom:5px">what is it that I can do with C# and WPF that can't be done with Silverlight?</li> </ol><br/>Also, dear members, do you have any favorite resource which teaches animation and design side of WPF?<br/><br/>Thank you very much.</span>Sun, 22 Nov 2009 10:56:27 Z2009-11-25T18:12:57Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/656c724a-e32e-4f50-802d-04c86baa1f42http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/656c724a-e32e-4f50-802d-04c86baa1f42algateshttp://social.msdn.microsoft.com/Profile/en-US/?user=algatesdrawing cross hair +C#<div class=KonaBody>     i'm trying to draw crosshairs that follow the mouse around the screen. The following code works. but not quite, it draws a new crosshair for every mouse move, but doesn't remove the old one, so i end up with a screen full of vertical and horizontal lines.<br/><br/>how do i remove the last lines drawn on every mouse move?<br/><br/>public void MyMouseMove( Object sender, MouseEventArgs e )<br/> { <br/> <br/> Pen blackPen = new Pen(Color.FromArgb(128,0,0,255), 1); // Pen blackPen = new Pen(Color.FromArgb(0,0,0,255), 1);<br/>   Graphics g = SelectionRectangle.ActiveForm.CreateGraphics();<br/> // Create coordinates of points that define line.<br/> float formLeft = this.Left;<br/> float formTop = this.Top ;<br/> float formRight = this.Right ;<br/> float formBottom = this.Bottom ;<br/> mouseX = e.X ;<br/> mouseY = e.Y ;<br/> // Draw line to screen.<br/> g.DrawLine(blackPen,0,mouseY,mouseX,mouseY );<br/> g.DrawLine(blackPen, mouseX, 0, mouseX,mouseY);<br/> g.DrawLine(blackPen, formRight, mouseY, mouseX, mouseY);<br/> g.DrawLine(blackPen, mouseX, formBottom,mouseX, mouseY);<br/></div><hr class="sig">algatesTue, 24 Nov 2009 04:10:58 Z2009-11-25T18:08:50Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d1657e2f-e02b-4afe-af44-b7778ea7a76dhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d1657e2f-e02b-4afe-af44-b7778ea7a76dFyerEgghttp://social.msdn.microsoft.com/Profile/en-US/?user=FyerEggC# Syntax Coloring<p>Ok, I've been working on a working syntax coloring code that works with a richTextBox, but I can't get it quite right. The code I have is just slightly buggy, and I cant figure out how to fix it for the life of me.<br/><br/>I figured since the people are are experts that I could get some help. Here is the code I am using.<br/></p> <pre lang="x-c#">//This part goes right after Form1_Load [DllImport(&quot;user32.dll&quot;)] public static extern bool LockWindowUpdate(IntPtr hWndLock); public Regex keyWords1 = new Regex(&quot;int|double|float|string|bool|true|false|define&quot;); public Regex keyWords2 = new Regex(&quot;if|then|else|elseif|function|end|begin&quot;); //This part goes into &quot;richTextBox1_TextChanged&quot; int selected = richTextBox1.SelectionStart; try { LockWindowUpdate(richTextBox1.Handle); foreach (Match keyWordMatch in keyWords1.Matches(richTextBox1.Text.ToLower())) { richTextBox1.Select(keyWordMatch.Index, keyWordMatch.Length); richTextBox1.SelectionColor = Color.Blue; richTextBox1.SelectionStart = selected; richTextBox1.SelectionColor = Color.Black; } foreach (Match keyWordMatch in keyWords2.Matches(richTextBox1.Text.ToLower())) { richTextBox1.Select(keyWordMatch.Index, keyWordMatch.Length); richTextBox1.SelectionColor = Color.Orange; richTextBox1.SelectionStart = selected; richTextBox1.SelectionColor = Color.Black; } } finally { LockWindowUpdate(IntPtr.Zero); } richTextBox1.Select(selected, 0); richTextBox1.SelectionStart = selected;</pre> Thank you for any help.Tue, 24 Nov 2009 18:43:00 Z2009-11-25T18:02:54Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/694f13cf-d3a7-45d3-8418-949412389377http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/694f13cf-d3a7-45d3-8418-949412389377Mitja Boncahttp://social.msdn.microsoft.com/Profile/en-US/?user=Mitja%20BoncaStored procedures and dependenceI am doing pretty well with 3-tier architecture, but there is one thing that I can not  figurated it out. How to write a procedure, what will depend on a selected item (in my case in a listBox).  <div><br/></div> <div>I can not write directly like WHERE Author.Name = '&quot; + listBox1.SelectedItem + &quot;'  - like I was doing that before.</div> <div><br/></div> <div>Now it`s needed a bit different approach, becuase I am not doing directls with the database.</div> <div><br/></div> <div>In Data Access Layer I call a stored procedure which looks like:</div> <div> <pre lang="x-c#">ALTER PROCEDURE GetBooksSelectedAuthor @name varchar = null AS if @name is not null BEGIN SELECT Books.Title FROM Books, Authors WHERE Authors.IDAuthor = Books.IDAuthorFK AND Author.Name = @name END</pre> How can I define that @name is bound to selected Item in listBox1?</div>Wed, 25 Nov 2009 14:33:51 Z2009-11-25T17:40:03Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/e22d66de-8a0e-47a3-ad7c-6b2be8ef829bhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/e22d66de-8a0e-47a3-ad7c-6b2be8ef829bZexkshttp://social.msdn.microsoft.com/Profile/en-US/?user=ZexksExtreme refreshes from ProgressChanged event is making Readout labels unreadable.I've got a backgroundworker thread running a comparison between two tables in a database. As each record of each table is compared I fire off a worker.ReportProgress containing a custom object with my return values. The problem I'm having is that the actual comparison is so fast that it causes the UI thread to refresh so much that the label text never has a chance to finish it's redaw, subsequently causing them to all become unreadable.<br/> <br/> my progresschanged event:<br/> <div style="color:Black;background-color:White"> <pre>&lt;br/&gt; <span style="color:Blue">private</span> <span style="color:Blue">void</span> bgwExecuteCompare_ProgressChanged(<span style="color:Blue">object</span> sender, ProgressChangedEventArgs e)&lt;br/&gt; {&lt;br/&gt; pbProgress.Value = e.ProgressPercentage;&lt;br/&gt; CompTracker tmpTracker = (CompTracker)e.UserState;&lt;br/&gt; &lt;br/&gt; lblReportDB.Text = tmpTracker.CurDB;&lt;br/&gt; lblReportTBL1.Text = tmpTracker.TBL1;&lt;br/&gt; lblReportTBL2.Text = tmpTracker.TBL2;&lt;br/&gt; lblReportRecCount1.Text = Convert.ToString(tmpTracker.TotalTBL1Records);&lt;br/&gt; lblReportRecCount2.Text = Convert.ToString(tmpTracker.TotalTBL2Records);&lt;br/&gt; lblReportCurrentRec.Text = Convert.ToString(tmpTracker.CurRec) + <span style="color:#a31515">&quot; of &quot;</span> + &lt;br/&gt; Convert.ToString(tmpTracker.TotalTBL1Records + tmpTracker.TotalTBL2Records);&lt;br/&gt; }&lt;br/&gt; </pre> </div> During runtime, all i see is the UI thread constantly refreshing to the point of uselessness. Have tried using the suspend/resume layout tricks to no avail. There's no DataSource property for labels as there are for textboxes. Was wondering if anyone had any idea's as to how to stop the continual refreshes, or of a way to simply update the label text without triggering the redraw (which is i think what is causing all the refreshes). The progress bar seems to update correctly, it flashes with varying degree's of 'filledness' during the process, but since it's so fast (on my test data) it's hard to tell if it's actually counting right. I've also tried using the CLR debugger but being as this is multithreaded when i put breakpoints in, it freezes the UI thread as well, so I can't see the updates as they come through. I do however see all the correct inputs coming through from the UserState pass, so I know the info is getting through it just seems like it doesn't have enough time to redraw the control before the next update is sent and it's forced to redraw again.Sat, 21 Nov 2009 00:01:16 Z2009-11-25T17:35:56Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/e81a71b1-ecac-471b-89ab-1f0e4e6a04c7http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/e81a71b1-ecac-471b-89ab-1f0e4e6a04c7MoCoderhttp://social.msdn.microsoft.com/Profile/en-US/?user=MoCoderHow to launch a MSAccess1007 distrbutable .accdr file. I am trying to launch a MSAccess1007  distrbutable .accdr file. in a C# form VS2008 with the code below.<br/>But get a message: &quot;Could not load file or assembly.  The assembly was expected to contain an assembly manifest.&quot;<br/>What is the right way to launch a .accdr file from a C# windows form application?<br/><br/><span style="font-size:x-small"><font size=2> <p>System.</p> </font></span> <p><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">AppDomain</span></span><span style="font-size:x-small"> newDomain = System.</span><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">AppDomain</span></span><span style="font-size:x-small">.CreateDomain(</span><span style="font-size:x-small;color:#a31515"><span style="font-size:x-small;color:#a31515">&quot;NewApplicationDomain&quot;</span></span><span style="font-size:x-small">);<font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#008000"><span style="font-size:x-small;color:#008000">// Load and execute an assembly:</span></span></p> <span style="font-size:x-small"><font size=2> <p>newDomain.ExecuteAssembly(</p> </font></span> <p><span style="font-size:x-small;color:#a31515"><span style="font-size:x-small;color:#a31515">&quot;C:\\Program Files\\CALLMaster\\Data\\CMODLoadPhone.accdr&quot;</span></span><span style="font-size:x-small">);<font size=2> <p> </p> </font></span></p> <p><span style="font-size:x-small;color:#008000"><span style="font-size:x-small;color:#008000">// Unload the application domain:</span></span></p> <span style="font-size:x-small"><font size=2> <p>System.</p> </font></span> <p><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">AppDomain</span></span><span style="font-size:x-small">.Unload(newDomain);<br/><br/>Thanks<br/>Morris</span></p>Sat, 21 Nov 2009 03:46:53 Z2009-11-25T17:31:19Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/afce55ae-bfbf-45d3-a1d8-710b76e21e20http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/afce55ae-bfbf-45d3-a1d8-710b76e21e20Attila Adorjanhttp://social.msdn.microsoft.com/Profile/en-US/?user=Attila%20AdorjanNullReferenceException on SqlDataAdapter.Fill(DataSet)<div>Hi!</div> <div><br/></div> <div>I'm keep getting a <strong>NullReferenceException </strong>at line: <strong>DA.Fill(DS)</strong>.</div> <div>I tried with SqlCommand.ExecuteReader() but it fails too.</div> <div><br/></div> <div>My select is a really simple one: &quot;SELECT * FROM TestTable&quot; which gives at least 10 result in an sql query. So the select is OK.</div> <div>SqlConnection is OK too, because I can Open() it.</div> <div><br/></div> <div><strong>Facts:</strong></div> <div><strong>-------</strong></div> <div><strong>This code is working fine on Windows Mobile 6.0 (device), but fails on Windows CE 5.0 (device)!</strong></div> <div><strong>I'm pretty sure, that I'm using correct version of SqlClient.dll.</strong></div> <strong>There was a problem in the database. The default collation was unsupported (so it thrown PlatformNotSupportedException), but I changed it to Latin1_General_CI_AI.</strong> <div><strong>I'm not using separate threads in my application.</strong></div> <div><strong>I'm developing the application in VS 2008, C#, .NET CF 3.5 with MSSQL database.</strong></div> <div><br/></div> <div>Begin code</div> <div>...</div> <div>            Connect(); // Open the connection</div> <div>            DataSet DS = new DataSet();</div> <div>            SqlDataAdapter DA = new SqlDataAdapter(Command, SQLConnection);</div> <div>            <strong>DA.Fill(DS); // ERROR</strong></div> <div>            return DS.Tables;</div> <div>...</div> <div>End code</div> <div><br/></div> <div>So my question is:</div> <div>---------------------</div> <div><strong>What am I doing wrong?</strong></div> <div><br/></div> <div>Thanks in advice!</div> <div>--------------------</div> <div>Attila Adorjan</div>Wed, 25 Nov 2009 16:19:33 Z2009-11-25T17:26:27Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/ca6f9115-0ce1-4b05-82be-9b28c49d9ae4http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/ca6f9115-0ce1-4b05-82be-9b28c49d9ae4Christopher Piszhttp://social.msdn.microsoft.com/Profile/en-US/?user=Christopher%20PiszSelectionChanged event - triggered before action completesI don't know if I am using the wrong event. I want to know when my user selects a row in my griddataview. So, I am using the selectionchanged event. Seems logical. However, the event is also triggered when the grid is created and when the grid is cleared. That would be fine, but the problem is....<br/><br/>When I call the clear method of the griddataview, it triggers the selectionchanged event <strong>before </strong>the grid is cleared.<br/>So my check:<br/> <pre lang="x-c#">if (gridBudgetSummaries.RowCount == 0) { return; }<br/><br/></pre> returns false. Windows tells me there are rows when I just called clear. Obviosuly this causes exceptions when I try to use the corresponding data.<br/>This seems rather buggy to me. Woudln't be the first time I cried out &quot;It's MS's fault&quot; and have been wrong though. Perhaps someone could explain this to me. How can I avoid this situation without doing something hacky like implementing a &quot;I am clearing right now&quot; flag.<br/><br/>Am I using the wrong event?<br/><br/><br/><br/>Wed, 25 Nov 2009 17:06:49 Z2009-11-25T17:37:12Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/4a4d48e2-2e9e-4530-b5f8-73bc188d5dedhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/4a4d48e2-2e9e-4530-b5f8-73bc188d5dednccsbim071http://social.msdn.microsoft.com/Profile/en-US/?user=nccsbim071small problem in Using System.Diagnostics.Process.Start to execute MySql.exeHi i have been creating windows forms application to create a dump of remote mysql database and than using the same dump to restore my local database.<br/> <br/>  I was successfully able to create a dump of remote mysql database using following method. I the code below i show both the mysql command and the C# process.start command to do the same thing. This was successful<br/> <br/> <strong>Command in mysql command prompt:</strong> <br/> D:\Program Files\wamp\bin\mysql\mysql5.0.51b\bin&gt;mysqldump --opt -h 65.13.19.54 -u root -proot --skip-lock-tables --databases posapplication&gt;test.sql<br/> <br/> <strong>Method statement in Process.Start:</strong> <br/> Process compiler = new Process();<br/> compiler.StartInfo.FileName = @&quot;D:\Program Files\wamp\bin\mysql\mysql5.0.51b\bin\mysqldump.exe&quot;;<br/> compiler.StartInfo.Arguments = &quot;--opt -h 65.13.19.54 -u root -proot --skip-lock-tables --databases posapplication -r test.sql&quot;;<br/> compiler.StartInfo.UseShellExecute = false;<br/> compiler.StartInfo.RedirectStandardOutput = true;<br/> compiler.StartInfo.CreateNoWindow = true;<br/> compiler.Start();<br/> Console.WriteLine(compiler.StandardOutput.ReadToEnd());<br/> compiler.WaitForExit();<br/> MessageBox.Show(&quot;Backup created successfully.&quot;);<br/> <br/> <strong>Note: guys above code work absolutely fine</strong> <br/> <br/> The problem is here: When i try to restore my local database from the dump file generated by above code. It just doesn't happen.  Now this time instead of  usgin mysqldump.exe i used mysql.exe which needs to be invoked to restore the database. In the code below i show both mysq command and C# Process.Start command. The Mysql command works just fine but my C# code won't do anything. <br/> <br/> <strong>Mysql Command: </strong> <br/> D:\Program Files\wamp\bin\mysql\mysql5.0.51b\bin&gt;mysql -h localhost -u root -proot posapplication &lt; test.sql<br/> <br/> <strong>Method statement in Process.Start:<br/> </strong> Process compiler = new Process();<br/> compiler.StartInfo.FileName = @&quot;D:\Program Files\wamp\bin\mysql\mysql5.0.51b\bin\mysql.exe&quot;;<br/> compiler.StartInfo.Arguments = @&quot;-r -h localhost -u root -proot posapplication &lt; D:\Program Files\wamp\bin\mysql\mysql5.0.51b\bin\test.sql &quot;;<br/> compiler.StartInfo.UseShellExecute = false;<br/> compiler.StartInfo.RedirectStandardInput = true;<br/> compiler.StartInfo.RedirectStandardOutput = true;<br/> compiler.StartInfo.CreateNoWindow = true;                               <br/> compiler.Start();<br/> compiler.StandardInput.Write(&quot;root&quot;);<br/> Console.WriteLine(compiler.StandardOutput.ReadToEnd());<br/> compiler.WaitForExit();<br/> MessageBox.Show(&quot;Database restored successfully.&quot;);<strong><br/> <br/> <br/> Now i see that the code to generate the dump actually works fine but using the same process if i try to restore my local database it just doesn't work. Of course above code in mysql works just fine and ok. But i need to do this on click of button in windows forms. I can also do this by executing the bat file, which i already tried and was successful. But i want to restore the local db by using the way i dumped the remote mysql db as shown above.<br/> <br/> In the code to restore the db please note guys, i think i  am wrong in passing the dump file to mysql command. see, there is a difference in way the dump file is given in mysqlcommand and in C# method. while passing the file in mysqldump it works fine, but i think during restore the passing of file parameter is wrong. Please guys take a look.<br/> <br/> This should be a simple problem for you guys<br/> Please help.<br/> <br/> Thanks</strong>Tue, 24 Nov 2009 04:51:43 Z2009-11-25T17:10:58Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/39d1fd0f-9f16-4009-8ffb-ff0c1a9c9a6ahttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/39d1fd0f-9f16-4009-8ffb-ff0c1a9c9a6aChristopher Piszhttp://social.msdn.microsoft.com/Profile/en-US/?user=Christopher%20PiszC# Inheritance - initialize child with parentComing from C++ I could use a chid class' copy constructor and pass it a parent class as an argument. I got an error when attempting to do this in C#.<br/>How do I initialize my derived class with a base class object?  (assuming I can implement what the derived members would be set to)<br/><br/>Here is what I tried and got my error<br/> <pre lang="x-c#">class Parent { public int m_data; public Parent() { m_data = 0; } public Parent(Parent rhs) { m_data = rhs.m_data } } class Child : Parent { public int m_other; public Child() : base() { m_other = 0; } public Child(Child rhs) : base(rhs) { m_other = rhs.m_other; } } //.... Parent foo = new Parent(); Child bar = new Child(foo); // &lt;---Error </pre> <br/>Wed, 25 Nov 2009 01:10:51 Z2009-11-25T17:04:48Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/74d4be51-1de3-4de5-b57a-1ca18dea75c3http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/74d4be51-1de3-4de5-b57a-1ca18dea75c3Chris62http://social.msdn.microsoft.com/Profile/en-US/?user=Chris62Adding properties at runtime to an objectI need to add properties to an existing object at runtime.  Our project has a MemberInfo object that has some standard properties(such as FirstName, LastName, etc...).  Our clients can go in and add Custom Fields in the database, we would like to be able to display a list of the members with the Custom Fields(and their values) in a grid.  We bind a list of objects to the grid and each property with a custom attribute will be displayed.<br/> <br/> Namespace: Company.Net.Library.Member<br/> Assembly: Company.Net.Library.Member.dll<br/> The stored procedure returns an xml blob like the following:<br/> (normal stuff like FirstName get read in the normal way)<br/> &lt;CustomFields&gt;<br/> &lt;CustomField Name=&quot;HairColor&quot;&gt;Brown&lt;/CustomField&gt;<br/> &lt;CustomField Name=&quot;ShoeSize&quot;&gt;9&lt;/CustomField&gt;<br/> (there could be additional child nodes)<br/> &lt;/CustomFields&gt;<br/> <br/> In the class I read from the datareader and convert to a dictionary with the key being the property name(example:HairColor or ShoesSize) and the Value being the innertext(example Brown or 9)  That part seems to be working ok.  But what I need to do is add properties to the existing object.<br/> <br/> membersList is a List&lt;MemberInfo&gt;<br/> HasCustomFields is a boolean the will tell if there are custom fields(not all customers have custom fields)<br/> CustomFields is property of type Dictionary&lt;string, string&gt; that contains the above mentioned key, value pair.  All the added properties can be strings<br/> ObjectFieldAttribute is a custom attribute we defined(inherits from Attribute), the constructor takes three boolean.<br/> <br/> What I have so far:<br/> if (membersList.Count &gt; 0)<br/> {<br/>     if (membersList[0].HasCustomFields)<br/>     {<br/>         #region add property to class<br/> <br/>         AppDomain domain = Thread.GetDomain();<br/>         AssemblyName name = new AssemblyName();<br/>         name.Name = &quot;MemberInfo&quot;;<br/> <br/>         AssemblyBuilder assBuilder = domain.DefineDynamicAssembly(name, AssemblyBuilderAccess.RunAndSave);<br/>         ModuleBuilder modBuilder = assBuilder.DefineDynamicModule(name.Name, name.Name + &quot;.dll&quot;);<br/> <br/>         // just for testing<br/>         int origCount = typeof(MemberInfo).GetProperties().Length;<br/> <br/>         #region  add each property one at a time<br/> <br/>         foreach (KeyValuePair&lt;string, string&gt; entry in membersList[0].CustomFields)<br/>         {<br/>             try<br/>             {<br/>                 TypeBuilder typeBuilder = modBuilder.DefineType(entry.Key, TypeAttributes.Public);<br/>                 FieldBuilder fieldBuilder = typeBuilder.DefineField(entry.Key, typeof(string), FieldAttributes.Private);<br/>                 PropertyBuilder propBuilder = typeBuilder.DefineProperty(entry.Key, PropertyAttributes.None, typeof(string), null);<br/> <br/>                 // Create the custom attribute ObjectFieldAttribute<br/>                 Type[] ctorParams = new Type[] { typeof(bool), typeof(bool), typeof(bool) };<br/>                 ConstructorInfo constructor = typeof(ObjectFieldAttribute).GetConstructor(ctorParams);<br/>                 CustomAttributeBuilder custAttBuilder = new CustomAttributeBuilder(constructor, new object[] { true, true, true });<br/> <br/>                 //fieldBuilder.SetValue(info, entry.Value);<br/>                 propBuilder.SetCustomAttribute(custAttBuilder);<br/> <br/>                 MethodAttributes getSetAttr = MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig;<br/> <br/>                 // create the get method of the property<br/>                 MethodBuilder getMethodBuilder = typeBuilder.DefineMethod(&quot;get_&quot; + entry.Key, getSetAttr, typeof(string), Type.EmptyTypes);<br/> <br/>                 ILGenerator getILgen = getMethodBuilder.GetILGenerator();<br/>                 getILgen.Emit(OpCodes.Ldarg_0);<br/>                 getILgen.Emit(OpCodes.Stfld, fieldBuilder);<br/>                 getILgen.Emit(OpCodes.Ret);<br/> <br/>                 propBuilder.SetGetMethod(getMethodBuilder);<br/> <br/>                 // create the set method of the property<br/>                 MethodBuilder setMethodBuilder = typeBuilder.DefineMethod(&quot;set_&quot; + entry.Key, getSetAttr, null, new Type[] { typeof(string) });<br/> <br/>                 ILGenerator setILgen = setMethodBuilder.GetILGenerator();<br/>                 setILgen.Emit(OpCodes.Ldarg_0);<br/>                 setILgen.Emit(OpCodes.Ldarg_1);<br/>                 setILgen.Emit(OpCodes.Stfld, fieldBuilder);<br/>                 setILgen.Emit(OpCodes.Ret);<br/> <br/>                 propBuilder.SetGetMethod(setMethodBuilder);<br/> <br/>                 Type generated = typeBuilder.CreateType();<br/> <br/>                 PropertyInfo[] properties = generated.GetProperties();<br/>             }<br/>             catch (Exception ex)<br/>             {<br/> <br/>             }<br/>         }<br/> <br/>         // just for testing<br/>         int newCount = typeof(MemberInfo).GetProperties().Length;<br/> <br/>         // erroring out for some reason<br/>         //assBuilder.Save(name.Name + &quot;.dll&quot;);<br/> <br/>         #endregion<br/> <br/>         #endregion<br/> <br/>         #region Add values to the new properties<br/> <br/>         for (int i = 0; i &lt; membersList.Count; i++)<br/>         {<br/>             MemberInfo info = membersList[i];<br/>             if (info.HasCustomFields)<br/>             {<br/>                 foreach (KeyValuePair&lt;string, string&gt; entry in info.CustomFields)<br/>                 {<br/>                     // populate each new field with data<br/>                 }<br/>             }<br/>         }<br/> <br/>         #endregion<br/>     }<br/> }<br/>Mon, 23 Nov 2009 15:03:57 Z2009-11-25T17:03:50Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/bd0c6c71-5c9c-4ee7-8dfe-4e71b7464be2http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/bd0c6c71-5c9c-4ee7-8dfe-4e71b7464be2Boki_thegamehttp://social.msdn.microsoft.com/Profile/en-US/?user=Boki_thegameHow to take variable from other class by Value?Hi,<br/> I am beginner in this job and i want a little help about this problem.<br/> I want to take variable from other class by value. <br/> I have getters and setters of that variable but from the other class that constructor returns null.<br/> <div style="color:Black;background-color:White"> <pre> <span style="color:Blue">public</span> <span style="color:Blue">string</span> user;<br/>  <span style="color:Blue">public</span> <span style="color:Blue">string</span> userGetSet {<span style="color:Blue">get</span> {<span style="color:Blue">return</span> user;}<span style="color:Blue">set</span> {user= value;}}<br/>  <span style="color:Blue">private</span> <span style="color:Blue">void</span> txtLogirajSe_Click(<span style="color:Blue">object</span> sender, EventArgs e) {<br/>  <span style="color:Blue">if</span> (txtKorisnik.Text != <span style="color:#a31515">&quot;&quot;</span> &amp;&amp; txtSifra.Text != <span style="color:#a31515">&quot;&quot;</span> ) {<br/>  <span style="color:Blue">var</span> query= <span style="color:Blue">from</span> x <span style="color:Blue">in</span> db.TKorisnicis <span style="color:Blue">where</span> txtSifra.Text == x.sifra &amp;&amp; txtKorisnik.Text == x.korisnik <span style="color:Blue">select</span> x.korisnik;<br/>  <span style="color:Blue">string</span> localUser= <span style="color:#a31515">&quot;&quot;</span> ;<br/>  <span style="color:Blue">foreach</span> (<span style="color:Blue">var</span> y <span style="color:Blue">in</span> queryDaliPostoiTojUser) {<br/>  localUser= y;<br/>  } <br/> <span style="color:Blue">this</span> .userGetSet = localUser;<br/>  <span style="color:Blue">if</span> (localUser!= <span style="color:#a31515">&quot;&quot;</span> &amp;&amp; localUser!= <span style="color:Blue">null</span> ) <span style="color:Blue">this</span> .Close();<br/>  <span style="color:Gray">///</span> <span style="color:Green">when im typing here messagebox.show(userGetSet);the result is ok </span> } }<br/> <br/> <span style="color:Green">//and when i want to view that value from other form&lt;br/&gt;</span> <span style="color:Blue">private</span> <span style="color:Blue">void</span> menuStrip1_ItemClicked(<span style="color:Blue">object</span> sender, ToolStripItemClickedEventArgs e) {<br/>  Form1 ff = <span style="color:Blue">new</span> Form1();<br/>  MessageBox.Show(ff.userGetSet);<br/> }<span style="color:Green">// this returns null</span> </pre> </div>Tue, 24 Nov 2009 14:33:55 Z2009-11-25T17:03:27Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/072fe191-aa59-43bf-be1e-6a3c47d8c938http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/072fe191-aa59-43bf-be1e-6a3c47d8c938Mellonzzhttp://social.msdn.microsoft.com/Profile/en-US/?user=MellonzzInstantiating an object that implements IUIAutomation interfaceThe following MSDN link shows how to instantiate an object that implements the IUIAutomation interface, in C++<br/><br/><a href="http://msdn.microsoft.com/en-us/library/ee671202(VS.85).aspx">http://msdn.microsoft.com/en-us/library/ee671202(VS.85).aspx</a><br/><br/>This native COM API can also be used with managed code (as it is quicker than the managed API) but how do I instantiate an object that implements IUIAutomation in managed code?<br/><br/>Any help greatly appreciated for a relative newcomer.<br/><br/>Melanie<br/><br/>I should add that I have added a reference to use standard Com interop and can access the interface but I'm not sure how to instantiate.Wed, 25 Nov 2009 12:09:09 Z2009-11-25T17:01:14Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/b7f7671b-7d2f-4b53-bd94-540fe64dcee3http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/b7f7671b-7d2f-4b53-bd94-540fe64dcee3Agalohttp://social.msdn.microsoft.com/Profile/en-US/?user=AgaloStatic constructor usageI was reading about static constructor in msdn. it states that <br/><br/> <ul> <li> <p>A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.</p> </li> <li> <p>Static constructors are also useful when creating wrapper classes for unmanaged code, when the constructor can call the <strong>LoadLibrary</strong> method</p> </li> </ul> Can anyone elaborate above 2 points with suitable examplesWed, 25 Nov 2009 10:29:48 Z2009-11-25T16:57:49Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/67ee2ddb-d20b-4508-b6c6-f9afcee9627ehttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/67ee2ddb-d20b-4508-b6c6-f9afcee9627ecode_warriorhttp://social.msdn.microsoft.com/Profile/en-US/?user=code_warriorI've already installed VSTS 2008 but i need install VS2K3 EA, is this possible?Hi friend, <br/><br/>I've tried find a place to put this thread but couldnt find an up-to-date thread for VS installations....however....<br/><br/>I've already installed VSTS2008 but i need to install VS2K3 Enterprise Architect (i used to have to in my system). The reason i want install is that i want to install visio but only visio that i could find is the one that came with VS2K3 EA, so i have install a minimal files of VS2K3 EA to install visio for EA... <br/><br/>is it possible to install VS2K3 EA while having VSTS2008 in the system? <br/><br/>thanksSun, 22 Nov 2009 04:42:05 Z2009-11-25T16:56:41Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/92931481-956f-41b2-af32-3ae095e80e0fhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/92931481-956f-41b2-af32-3ae095e80e0fAbe119http://social.msdn.microsoft.com/Profile/en-US/?user=Abe119Find if Timer exists on the Formhi everyone,<br/> <br/> How could I know if the form has a timer defined or not? (not runtime design)<br/> <br/> Suppose the timer name is &quot;timer1&quot;. I tried this way, but not working:<br/> <br/> Control[] seq = Controls.Find(&quot;timer1&quot;, true);<br/> if (seq.Count() == 0)<br/>     MessageBox.Show(&quot;not found&quot;);<br/> else<br/>     MessageBox.Show(&quot;found&quot;);<br/> <br/> <br/> <br/> Can anyone help me with this? Any ideas will be really appreciated.<br/> <br/> Regards,<br/> <br/> <br/>Wed, 25 Nov 2009 12:14:35 Z2009-11-25T16:53:56Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/a05c51af-2ee3-4af2-9c3d-d8fbc627ec12http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/a05c51af-2ee3-4af2-9c3d-d8fbc627ec12BBauer42http://social.msdn.microsoft.com/Profile/en-US/?user=BBauer42DataBind between two user controls<p>Is it possible to DataBind a CheckBox's Checked property on one user control to a panel's Enabled property on a different user control (not in WPF). Does anyone have a small example of something like this? Thanks.</p>Tue, 04 Aug 2009 14:36:15 Z2009-11-25T16:53:48Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/4e9511b8-237d-4154-baa7-f6bf1f1cbb94http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/4e9511b8-237d-4154-baa7-f6bf1f1cbb94Sara4http://social.msdn.microsoft.com/Profile/en-US/?user=Sara4tab delimiter in csv (StringBuilder)I've been trying to create a tab delimited csv file from a string builder.<br/> <br/> I create a string builder.<br/> <br/> I convert it to byte array.<br/> byte[] bytes = System.Text.Encoding.Default.GetBytes(streamBuilder.ToString());<br/> <br/> Later on, byte[] bytes is used to create a .csv file.<br/> <br/> The problem is that the tabs are not read correctly. Instead of having every  delimited value in it's own cell, I get this (in one cell):<br/> Redni broj□Datum valute□Datum obrade    <br/> <br/> <br/> If I change the Encoding to UTF8<br/> byte[] bytes = System.Text.Encoding.UTF8.GetBytes(streamBuilder.ToString());<br/> tabs work correctly but I don't see the language specific letters  (defualt encoding is Central European).<br/> <br/> Any ideas how to solve this problem?<br/>Wed, 25 Nov 2009 11:43:02 Z2009-11-25T16:50:59Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d4d63fe5-3666-4d28-872f-0c4dee60b2ebhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d4d63fe5-3666-4d28-872f-0c4dee60b2ebHelen.Whttp://social.msdn.microsoft.com/Profile/en-US/?user=Helen.WHow to close an application opened by Activator.CreateInstanceHi there,<br/>I am implementing a Womdows Form application which creates an object by calling Activator.CreateInstance. But the apppication referred by the object is not closed when the main application exits. I tried to call ReleaseComObject inside the FormClosingEventHandler but in vain.<br/><br/>My question is: how to programmatically close the application opened by Activator.CreateInstance? Thanks a lot!Wed, 18 Nov 2009 21:32:04 Z2009-11-25T16:48:05Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/0540eba8-5725-4176-8c97-d81fc8a17c88http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/0540eba8-5725-4176-8c97-d81fc8a17c88daNewGuyhttp://social.msdn.microsoft.com/Profile/en-US/?user=daNewGuyC# and JavaScript variablesHello,<br/>I have created a control that is using the Google Map API to display points to a map. It all works but the key to register the Google API can change so I would like to somehow put it in the web.config. It currently is set in the ascx page like this:<br/><br/> <pre lang="x-c#">&lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;sensor=false &amp;amp;key=ABQIAAAAwevTcGKnP0RB8m8l-cwNgRQiwzL55ux5xs4VDD3WrzjBHisBGERXaGLCLd2E0vXsg7cJ2h-Bx52pXw&quot; type=&quot;text/javascript&quot;&gt; &lt;/script&gt;</pre> Can anyone show me how to do that, if it is possible.<br/><br/>ThanksWed, 25 Nov 2009 15:44:09 Z2009-11-25T20:49:56Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/40f9bf1f-069c-4f06-aaff-937745758d82http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/40f9bf1f-069c-4f06-aaff-937745758d82sanjeev40084http://social.msdn.microsoft.com/Profile/en-US/?user=sanjeev40084log question?What is difference between these two codes? <div><br/></div> <div> <div> if( log.IsDebugEnabled) { log.Debug( &quot;exiting method1&quot; ); }</div> <div><br/></div> <div>or</div> <div><br/></div> <div> log.Debug(&quot;exiting  method1&quot;);</div> <div><br/></div> </div><hr class="sig">creativity..Tue, 24 Nov 2009 18:29:52 Z2009-11-25T16:22:19Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/2661181b-98c0-42c3-b5c2-967c4b7da86ahttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/2661181b-98c0-42c3-b5c2-967c4b7da86aabruzzoforteegentilehttp://social.msdn.microsoft.com/Profile/en-US/?user=abruzzoforteegentilevolatile longHI <div>I have just tried to use <br/><br/> <pre lang="x-c#">static volatile long _myVar; </pre> <br/>in in my C# code and it doesn't compile.</div> <div>Having a look at the MSDN documentation this is absolutely correct.</div> <div>Do you know why this is not possible?</div> <div>Thanks</div>Tue, 24 Nov 2009 15:58:26 Z2009-11-25T16:15:35Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5670442f-c7ad-4d5a-94a1-cc2eed34d096http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5670442f-c7ad-4d5a-94a1-cc2eed34d096Christopher Piszhttp://social.msdn.microsoft.com/Profile/en-US/?user=Christopher%20PiszDataGridView - Put the data inI am unclear on how to insert the data into my datagridview object.<br/>I have a class that contains all the data to put in a row, and some extra. <br/><br/>1) I see there is a DataGridRow object that I can add, but that data grid row wants an array of &quot;objects&quot;. Not sure if writing some long convoluted code to get an array of objects from my class is needed.<br/><br/>2) I know there is data binding where you just &quot;bind&quot; it to an object such as my class, but my class isn't 1 for 1 with what goes in rows and I've only seen an exampe of this using a dataset or an array, but not a custom class.<br/><br/>3) What other options are there?<br/><br/>I imagine there is some kind of [][]= or something?<br/><br/>Here is the block of interest<br/> <pre lang="x-c#"> reader = command.ExecuteReader(); while (reader.Read()) { BudgetSummary budgetSummary = new BudgetSummary(); budgetSummary.m_scenarioID = scenarioID; budgetSummary.m_accountID = (reader[&quot;A&quot;] == DBNull.Value) ? 0 : Convert.ToInt32(reader[&quot;A&quot;]); budgetSummary.m_accountDesc = (reader[&quot;B&quot;] == DBNull.Value) ? &quot;&quot; : reader[&quot;B&quot;].ToString(); budgetSummary.m_accountNum = (reader[&quot;C&quot;] == DBNull.Value) ? &quot;&quot; : reader[&quot;C&quot;].ToString(); budgetSummary.m_currentBudget = (reader[&quot;D&quot;] == DBNull.Value) ? 0 : Convert.ToInt32(reader[&quot;D&quot;]); budgetSummary.m_currentActual = (reader[&quot;E&quot;] == DBNull.Value) ? 0 : Convert.ToInt32(reader[&quot;E&quot;]); budgetSummary.m_currentForecast = (reader[&quot;F&quot;] == DBNull.Value) ? 0 : Convert.ToInt32(reader[&quot;F&quot;]); budgetSummary.m_suggestedBudget = (reader[&quot;G&quot;] == DBNull.Value) ? 0 : Convert.ToInt32(reader[&quot;G&quot;]); budgetSummary.m_nextYearBudget = (reader[&quot;H&quot;] == DBNull.Value) ? 0 : Convert.ToInt32(reader[&quot;H&quot;]); budgetSummaries.Add(budgetSummary); DataGridViewRow row = new DataGridViewRow(); row.SetValues(.....); gridByYear.Rows.Add(row); }</pre>  Tue, 24 Nov 2009 22:57:57 Z2009-11-25T16:09:14Zhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d4e96d56-2e0c-4d6b-a402-acfbf52e174dhttp://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d4e96d56-2e0c-4d6b-a402-acfbf52e174dobrienkevhttp://social.msdn.microsoft.com/Profile/en-US/?user=obrienkevCreate DataGridViews From Multiple Result SetsHi,<br/>I have a SQL Stored Procedure that returns multiple result sets.<br/><br/>How do I create a DataGridView for each result set?<br/><br/>Thanks.Wed, 25 Nov 2009 15:45:51 Z2009-11-25T15:45:52Z