Forum Visual C# GeneralGeneral discussion and questions regarding Visual C# -- including best practices on developing with C# in VS, documentation, setup, and samples.© 2009 Microsoft Corporation. Tous droits réservés.Sun, 29 Nov 2009 13:14:29 Z24becc9b-b984-47b2-a748-a62e38c0066fhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/17b153a9-f271-4861-bc31-055e89bc5719http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/17b153a9-f271-4861-bc31-055e89bc5719DavidThi808http://social.msdn.microsoft.com/Profile/fr-FR/?user=DavidThi808Free book: No Bugs!<img src="http://blogs.windwardreports.com/.a/6a0115711bf0ae970b012875e00c90970c-pi" alt="" align=left> <p>I wrote this book in what now looks like the dawn of antiquity. I was on the Windows 95 development team at the time – C++ was still new, we still wrote the time critical parts in assembler, and Java was a word for coffee. It was a challenging world back then. Not better than today, not worse – but different challenges.</p> <p>I went back and looked at what I wrote. A lot of it is specific to C, C++, and assembler. Some of it is specific to the state of the industry at that time. And those parts will only be of interest to a few with a large degree of curiosity about that time. A bit more will be of interest to people still writing C++ in an unmanaged environment.</p> <p>But the first two chapters, those are still every bit as relevant today as they were when the book was written. I think most developers can be well served by reading this as it takes a philosophical look at how to write code with fewer bugs.</p> <p>You can download the entire book <strong>for free</strong> at <a href="http://www.windwardreports.com/free.htm">No Bugs!</a> You may forward the free copy to friends, post it on your own website, etc. Below is a short excerpt from chapters 1 &amp; 2 if you want a peek before downloading.</p> <p style="margin-left:36pt">One interesting note, in chapter 2 it declares bugs should be called <strong>Massive ____ Ups</strong>. The use of the F word had to be approved by a Vice President at the publisher and I think to this day No Bugs! Remains the one programming book from a major publisher where the word appears.</p> download <a href="http://www.windwardreports.com/free.htm">No Bugs!</a><hr class="sig">Windward Reports - <a href="http://www.windwardreports.com">World's Greatest SharePoint Reporting &amp; DocGen</a>Sun, 29 Nov 2009 02:49:00 Z2009-11-29T13:14:29Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/cb234a84-3449-494d-bcd9-7827c3f13371http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/cb234a84-3449-494d-bcd9-7827c3f13371alainkkkhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=alainkkkfilter hi how do i act the rowfilter to have the autocomplete textbox feature? <div><br/></div> <div> <pre><pre> private void txtCodeSearch_TextChanged(object sender, EventArgs e) { dv.RowFilter =&quot; Operations like '&quot;+ txtCodeSearch.Text+&quot;%'&quot;;</pre> <br/></pre> i tried this above, but it canot fulfill the needs of my requirement.<br/><br/></div> <div>given the sample, </div> <div>111</div> <div>1122</div> <div>44</div> <div>55</div> <div>abc</div> <div>matthew</div> <div><br/></div> <div>when i type in 1 in the textbox, it should filter those data without the 1 infront. left with just 111, 1122</div> <hr class=sig> alainSun, 29 Nov 2009 12:43:16 Z2009-11-29T13:12:53Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/8a5ff52e-cbfa-4546-b14f-7ca24755bfadhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/8a5ff52e-cbfa-4546-b14f-7ca24755bfadnemesiscsharphttp://social.msdn.microsoft.com/Profile/fr-FR/?user=nemesiscsharpHow to pass data from form1 to form2?Got a problem in passing a value from form1's textbox to form2's textbox.<br/> By the way i am using mysql connection.<br/> <br/> Can someone help me? :) thanksSat, 28 Nov 2009 02:16:41 Z2009-11-29T13:09:33Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/41716995-9320-4925-a66b-80f9c313a283http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/41716995-9320-4925-a66b-80f9c313a283alainkkkhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=alainkkkshorten my codehi how do i shorten this junk of code <div> <pre lang="x-c#"><pre> private void toolStrip_Operation_Click(object sender, EventArgs e) { OperationForm limo = new OperationForm(); toolStripContainer1.ContentPanel.Controls.Clear(); toolStripContainer1.ContentPanel.Controls.Add(limo); limo.Dock = DockStyle.Fill; }</pre> <br/></pre> into seomthing like this below?</div> <div> <pre lang="x-c#"> private void toolStrip_Operation_Click(object sender, EventArgs e) { OperationForm limo = new OperationForm(); OpenForm(limo); } private void OpenForm(object sender) { toolStripContainer1.ContentPanel.Controls.Clear(); toolStripContainer1.ContentPanel.Controls.Add(sender); sender = DockStyle.Fill; }</pre> this is because i need to reuse this code for my others toolstrip</div><hr class="sig">alainSat, 28 Nov 2009 13:16:41 Z2009-11-29T11:57:13Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/63a2fac2-25d4-4c77-b529-d1bbe20aa6f9http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/63a2fac2-25d4-4c77-b529-d1bbe20aa6f9alexis4http://social.msdn.microsoft.com/Profile/fr-FR/?user=alexis4Disable windows hotkeys, C#Hello!<br/> <br/> I am developing a full screen mode application, where all windows hotkeys that exit application from full screen, need to be disabled. I could disable ALT+TAB, ALT+F4 and ALT+ESC using the following code I found in the internet:<br/> <br/> <div style="color:Black;background-color:White"> <pre><span style="color:Blue">namespace</span> MyNamespace { <span style="color:Blue">public</span> <span style="color:Blue">partial</span> <span style="color:Blue">class</span> MainForm : Form { <span style="color:Blue">#region</span> Dynamic Link Library Imports [DllImport(<span style="color:#a31515">&quot;user32.dll&quot;</span> )] <span style="color:Blue">private</span> <span style="color:Blue">static</span> <span style="color:Blue">extern</span> <span style="color:Blue">int</span> RegisterHotKey<br/> (IntPtr hwnd, <span style="color:Blue">int</span> id, <span style="color:Blue">int</span> fsModifiers, <span style="color:Blue">int</span> vk); [DllImport(<span style="color:#a31515">&quot;user32.dll&quot;</span> )] <span style="color:Blue">private</span> <span style="color:Blue">static</span> <span style="color:Blue">extern</span> <span style="color:Blue">int</span> UnregisterHotKey<br/> (IntPtr hwnd, <span style="color:Blue">int</span> id); <span style="color:Blue">#endregion</span> <span style="color:Blue">#region</span> Modifier Constants and Variables <span style="color:Green">// Constants for modifier keys</span> <span style="color:Blue">private</span> <span style="color:Blue">const</span> <span style="color:Blue">int</span> USE_ALT = 1; <span style="color:Blue">private</span> <span style="color:Blue">const</span> <span style="color:Blue">int</span> USE_CTRL = 2; <span style="color:Blue">private</span> <span style="color:Blue">const</span> <span style="color:Blue">int</span> USE_SHIFT = 4; <span style="color:Blue">private</span> <span style="color:Blue">const</span> <span style="color:Blue">int</span> USE_WIN = 8; <br/> <span style="color:Green">// Hot key ID tracker</span> <span style="color:Blue"> short</span> mHotKeyId = 0; <span style="color:Blue">#endregion</span> <span style="color:Blue">public</span> MainForm() { InitializeComponent(); RegisterGlobalHotKey(Keys.Tab, USE_ALT); <span style="color:Green">//Block Alt+TAB</span> RegisterGlobalHotKey(Keys.F4, USE_ALT); <span style="color:Green">//Block Alt+F4</span> RegisterGlobalHotKey(Keys.Escape, USE_ALT);<span style="color:Green">//Block Alt+ESC&lt;br/&gt;</span> } <span style="color:Blue">private</span> <span style="color:Blue">void</span> RegisterGlobalHotKey<br/> (Keys hotkey, <span style="color:Blue">int</span> modifiers) { <span style="color:Blue">try</span> { <span style="color:Green">// increment the hot key value - we are just identifying</span> <span style="color:Green">// them with a sequential number since we have multiples</span> mHotKeyId++; <span style="color:Blue">if</span> (mHotKeyId &gt; 0) { <span style="color:Green">// register the hot key combination</span> <span style="color:Blue">if</span> (RegisterHotKey(<span style="color:Blue">this</span> .Handle, mHotKeyId, modifiers, Convert.ToInt16(hotkey)) == 0) { <span style="color:Green">// tell the user which combination failed to register </span> <span style="color:Green">// this is useful to you, not an end user; the user</span> <span style="color:Green">// should never see this application run</span> MessageBox.Show(<span style="color:#a31515">&quot;Error: &quot;</span> + mHotKeyId.ToString() + <span style="color:#a31515">&quot; - &quot;</span> + Marshal.GetLastWin32Error().ToString(), <span style="color:#a31515">&quot;Hot Key Registration&quot;</span> ); } } } <span style="color:Blue">catch</span> { <span style="color:Green">// clean up if hotkey registration failed -</span> <span style="color:Green">// nothing works if it fails</span> UnregisterGlobalHotKey(); } } <span style="color:Blue">private</span> <span style="color:Blue">void</span> UnregisterGlobalHotKey() { <span style="color:Green">// loop through each hotkey id and</span> <span style="color:Green">// disable it</span> <span style="color:Blue">for</span> (<span style="color:Blue">int</span> i = 0; i &lt; mHotKeyId; i++) { UnregisterHotKey(<span style="color:Blue">this</span> .Handle, i); } } <span style="color:Green">//rest of user code</span> } } </pre> </div> <br/> I need to disable CTR+ESC and the Windows key (right and left). I called the RegisterGlobalHotKey function as below:<br/> <br/> <div style="color:Black;background-color:White"> <pre>RegisterGlobalHotKey(Keys.Escape, USE_CTRL); RegisterGlobalHotKey(Keys.None, USE_WIN); </pre> </div> <br/> The build is succesfull, but when programm runs I get an error, because the code enters the <em>if (RegisterHotKey(this.Handle, mHotKeyId, modifiers, Convert.ToInt16(hotkey)) == 0)</em> section in the <em>RegisterGlobalHotKey()</em> function.<br/> <br/> My questions are:<br/> 1. Why do I get an error with CTRL+ESC and not with ALT+ESC? How can I disable the Win key using <em>RegisterGlobalHotKey()</em> function call?<br/> 2. Can this function be called, so that 3-key combinations like CTRL+ALT+ESC can also be disabled?<br/> 3. Are there any other hotkeys combinations that exit user from full screen?Sun, 29 Nov 2009 10:23:11 Z2009-11-29T10:23:12Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/e409c813-2633-4416-996c-f06f348f527fhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/e409c813-2633-4416-996c-f06f348f527falainkkkhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=alainkkkthis failed in my rowfilter<span style="font-size:x-small"><font size=2> <p>Hi, i tried to perform a rowfilter with datetime below but was told that canot use the convert function in rowfilter.<br/>the date column has the full datetime value e.g. 11/29/2009 5:36:15 PM<br/>i want to perform rowfilter to filter only today date. please advice<br/><br/>dv = operation.SelectAll().DefaultView;<br/>dv.RowFilter =</p> </font></span> <p><span style="font-size:x-small;color:#a31515"><span style="font-size:x-small;color:#a31515">&quot;convert(varchar,Date, 101) = '#&quot;</span></span><span style="font-size:x-small"> + </span><span style="font-size:x-small;color:#2b91af"><span style="font-size:x-small;color:#2b91af">DateTime</span></span><span style="font-size:x-small">.Now.ToShortDateString() + </span><span style="font-size:x-small;color:#a31515"><span style="font-size:x-small;color:#a31515">&quot;#' &quot;</span></span><span style="font-size:x-small">;</span></p><hr class="sig">alainSun, 29 Nov 2009 10:07:59 Z2009-11-29T10:26:11Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/58d34bd6-141a-4acc-a7c9-53abcb0a88a8http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/58d34bd6-141a-4acc-a7c9-53abcb0a88a8code_warriorhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=code_warriorI need to intialize an object only once, hwo do i do this?Hi Friend, <br/><br/>I have a default constructor of the class applicant that initializes an and DataAdapter to a table<br/><br/>as:<br/><br/> <div style="color:black;background-color:white"> <pre><span style="color:blue">public</span> <span style="color:blue">class</span> Applicant { tblApplicantsTableAdapter daApplicants; <span style="color:blue">public</span> Applicant() { daApplicants = <span style="color:blue">new</span> tblApplicantsTableAdapter(); } } </pre> </div> In the Applicant class i have a I have MakeInstance method that should create an Applicant object as:<br/><br/> <div style="color:black;background-color:white"> <pre><span style="color:blue">public</span> List&lt;Applicant&gt; MakeInstances(<span style="color:blue">int</span> iInstanceCount) {<br/> List&lt;Applicant&gt; obCollecttion = <span style="color:blue">new</span> List&lt;Applicant&gt;();<br/><span style="color:blue"> for</span>(<span style="color:blue">int</span> i = 1; i &lt;= iInstanceCount; i++) { Applicant appObj = <span style="color:blue">new</span> Applicant(); obCollection.add(appObj); } } </pre> </div> The problem is if i create an object of Applcant using the defualt costructor for each instace it will create an instance dataadapter. But i want each object of applicant class to use only one instance of the dataadapter. How do i do this?<br/><br/>thanksSun, 29 Nov 2009 09:47:32 Z2009-11-29T10:01:23Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/e504a078-4efb-48b5-8872-41228469c5bchttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/e504a078-4efb-48b5-8872-41228469c5bcnemesiscsharphttp://social.msdn.microsoft.com/Profile/fr-FR/?user=nemesiscsharpI'ved got to bind the data from my datagridview to textbox.Text, but it seems the application is doing a delay when i select data from datagridview very fast..The problem is there is a delay of sometimes it couldn't catch up what i am selecting. Can someone help me? :)<br/> <br/> Here is my code.<br/> <br/> <pre>if (dataGridViewCustomer.SelectedRows.Count != 0) { textBox1.Text = Convert.ToString( dataGridViewCustomer.SelectedRows[0].Cells[1].Value ); dataGridViewCustomer.Update(); }</pre> Am i missing something? or is this a limitation from c#? hmmSat, 28 Nov 2009 01:30:00 Z2009-11-29T07:25:35Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/0bc5274b-6835-469e-81af-840b5ba37e49http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/0bc5274b-6835-469e-81af-840b5ba37e49drewdbhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=drewdbHow to play incomplete media fileHi,<br/><br/>I'm using BinaryWriter to write a video/audio to disk and want to play the file while it's being written. I have checked that the completed file is working. WMP doesn't seem to want to open it until it final.<br/><br/>This is what i'm doing.<br/><br/> <p><span style="font-size:x-small">fs </span><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">= </span></span><strong><span style="color:#008b8b;font-size:x-small"><span style="color:#008b8b;font-size:x-small">new </span></span><span style="color:#191970;font-size:x-small"><span style="color:#191970;font-size:x-small">FileStream</span></span></strong><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">(</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">@&quot;D:\\tst.avi&quot;</span></span><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">, </span></span><span style="font-size:x-small">FileMode</span><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">.</span></span><span style="font-size:x-small">CreateNew</span><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">, </span></span><span style="font-size:x-small">FileAccess</span><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">.</span></span><span style="font-size:x-small">Write</span><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">, </span></span><span style="font-size:x-small">FileShare</span><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">.</span></span><span style="font-size:x-small">Read</span><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">); <p> </p> <font size=2 color="#006400"><font size=2 color="#006400"> <p> </p> </font></font></span><font size=2 color="#006400"> <p> </p> </font></span></p> <p><span style="font-size:x-small">bw </span><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">= </span></span><strong><span style="color:#008b8b;font-size:x-small"><span style="color:#008b8b;font-size:x-small">new </span></span><span style="color:#191970;font-size:x-small"><span style="color:#191970;font-size:x-small">BinaryWriter</span></span></strong><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">(</span></span><span style="font-size:x-small">fs</span><span style="color:#006400;font-size:x-small"><span style="color:#006400;font-size:x-small">); <p>I've tried waiting for some time but still no luck.<br/><br/>Any help would be great.</p> </span></span></p><hr class="sig">new to .net and c#Sun, 29 Nov 2009 06:35:02 Z2009-11-29T06:35:02Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/ead69a43-464a-48b8-88cb-686cd3714423http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/ead69a43-464a-48b8-88cb-686cd3714423tosa.yasunarihttp://social.msdn.microsoft.com/Profile/fr-FR/?user=tosa.yasunariBitmap handling of 16bit gray tiff imageI'm quite annoyed by Bitmap reading a 16 bit gray tiff image.    When I do new Bitmap(filename), I get PixelFormat being Format32bppArgb and I get a black image.<br/> <br/> Is there any way to get Bitmap translated exactly what the original one is, i.e. getting Format16bppGrayScale?<br/> <br/> Thank you.Sun, 29 Nov 2009 05:27:01 Z2009-11-29T05:54:42Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/16a4cf6e-8140-43b2-a21f-744fc196e25ahttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/16a4cf6e-8140-43b2-a21f-744fc196e25anaturefreak827http://social.msdn.microsoft.com/Profile/fr-FR/?user=naturefreak827Problem setting accept button.I am trying to set the accept button on a form that is shown via a public static method. Right now the accept button is always stays at the first of five buttons. <div><br/></div> <div> <pre lang="x-c#"> public static string ShowBox(string txtMessage, string txtTitle) { newMessageBox = new MyMessageBox(); newMessageBox.AcceptButton = newMessageBox.Btn3; newMessageBox.label1.Text = txtMessage; newMessageBox.Text = txtTitle; newMessageBox.ShowDialog(); return Button_id; }</pre> <br/></div>Tue, 24 Nov 2009 21:15:51 Z2009-11-29T05:00:17Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/1cb3d57b-0de1-4d36-8d62-767f144d80echttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/1cb3d57b-0de1-4d36-8d62-767f144d80ecsagarhhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=sagarhusing MCI time macros in C# VS2008I am working on building a media player and I need to update a label which shows the current track position. I am using the following command to retrieve the position: <div><br/></div> <div>mciSendString(&quot;status MediaFile length&quot;, media_length, 256, IntPtr.Zero); // where MediaFile is the alias I have used for mpegvideo device</div> <div><br/></div> <div>I am using the following command to retrieve the hour component:</div> <div><br/></div> <div>int hour = MCI_HMS_HOUR(trackLength);</div> <div><br/></div> <div>The error I get is MCI_HMS_HOUR is not in the current context. </div> <div><br/></div> <div><br/></div> <div>Thank you.</div> <div><br/></div> <div><br/></div> <div>Sagar Hatekar</div> <div><br/></div>Sat, 28 Nov 2009 22:40:57 Z2009-11-29T03:02:43Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/59f48b37-8354-4468-93bb-8af9b0d47d84http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/59f48b37-8354-4468-93bb-8af9b0d47d84soandos3http://social.msdn.microsoft.com/Profile/fr-FR/?user=soandos3show the control as it is being dragged and droppedIs it possible to show the control as it is being dragged and dropped?<br/> What I have now is a bare bones drag and drop that redraws the control around the final mouse position.<br/> I tried to change the location property of the control, and that does work, but removes the drag and drop functionality, and cannot cross containers. Is there a solution to show the control as it is being moved?<br/> Thanks.Sun, 29 Nov 2009 01:24:40 Z2009-11-29T02:43:03Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/73af0cb4-3cd9-456f-844b-c05eeaae43c0http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/73af0cb4-3cd9-456f-844b-c05eeaae43c0Sri096http://social.msdn.microsoft.com/Profile/fr-FR/?user=Sri096how to run a X64 bit application from X86 excutable on a X64 machine.Hi,<br/><br/>I am trying to run qwinsta.exe from a X86 Visual Studio project, but every time I search for C:\Windows\System32\qwinsta.exe, app was throwing an exception FileNotFound. I know that the file was searched in C:\Windows\SysWOW64 from a X86 project or 32 bit application. <br/>And more over i didnt find 32 bit version of qwinsta in SysWOW64 folder. <br/><br/>Could somebody help me how could I access the files from System32 folder on X64 machine from a X86 project.  <br/> <br/>Any Project settings that I could change to access these. <br/><br/>The main constraint is I cant build my project with Options set to &quot;Any CPU&quot; or &quot;X64&quot;. I could only build set to &quot;X86&quot;.<br/><br/>Thanks in advance for help.<br/><br/>-Regards,<br/>Sri.<hr class="sig">Thanks, SriSat, 28 Nov 2009 11:18:54 Z2009-11-29T02:35:41Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/5c73b074-a7db-4a43-b656-50bee32734b5http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/5c73b074-a7db-4a43-b656-50bee32734b5AlexBB - Vista Ult64 SqlSer64 WinSer64http://social.msdn.microsoft.com/Profile/fr-FR/?user=AlexBB%20-%20Vista%20Ult64%20SqlSer64%20WinSer64ZedGraphI just spent a couple of hours trying to implement ZedGraph. I downloaded the dlls from SourceForge website:<br/><br/><a href="http://sourceforge.net/projects/zedgraph/files/">http://sourceforge.net/projects/zedgraph/files/</a><br/><br/>and dropped them into VS2008 ToolBox. I followed all instructions, opened up a new project and dropped the control on one of my Tabpages. The look is very good. What I don't understand is this. I am trying to use the tutorial, A Flexible Charting Library in .NET:<br/><br/><a href="http://www.codeproject.com/KB/graphics/zedgraph.aspx">http://www.codeproject.com/KB/graphics/zedgraph.aspx</a><br/><br/>and follow code samples which are also all over the web. it seems to me this latest version of the dlls is different from the one code samples relate to. I cannot invoke some classes and some methods are absent in the classes that are available. It also appears that come NameSpaces are rearranged. Before I spent another two hours I want to ask the public if anyone has had recent experience with the control. Am I doing something wrong?<br/><br/>For instance this code sample:<br/><br/>private void CreateGraph( ZedGraphControl zgc )<br/>{<br/>   // get a reference to the GraphPane<br/>   GraphPane myPane = zgc.GraphPane;<br/><br/>gives me compilation errors. ZedGraphControl  is not available as an object. I can get the Panel differently but I don't know how to connect it to the page or the graph.<br/><br/>This is how it works for me:<br/><br/>        private void CreateGraph ( ZedGraph zgc )<br/>        {<br/>            // get a reference to the GraphPane<br/>            ZedGraph.GraphPane myPane = new ZedGraph.GraphPane ( );            <br/>            // Set the Titles<br/>            myPane.Title.Text = &quot;My Test Graph\n(For CodeProject Sample)&quot;;<br/>            myPane.XAxis.Title.Text = &quot;My X Axis&quot;;<br/>            myPane.YAxis.Title.Text = &quot;My Y Axis&quot;;<br/><br/>Thanks.<br/><br/><br/><br/> <hr class=sig> AlexBSat, 28 Nov 2009 22:18:19 Z2009-11-29T01:15:58Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/954a8ab5-71dd-4a89-8e23-16051c6ef461http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/954a8ab5-71dd-4a89-8e23-16051c6ef461Gabriel Rotarhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=Gabriel%20RotarHow to get aero working with winforms usercontrolls?I have managed to get my form to use aero but I haven't realy found a way to apply aero to my controls, the only information I found was on a codeproject article, and that was using unmanaged c++Sat, 28 Nov 2009 22:24:55 Z2009-11-29T00:19:11Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/cdc20d3b-5d88-4f0f-aa23-e9edd4626f6dhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/cdc20d3b-5d88-4f0f-aa23-e9edd4626f6dayat yassinhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=ayat%20yassini don't know where to put this question but pleese answer me ,can we adjust swf file that doesnot have source code????hiii alll<br/> i hope you to answer me ..<br/> <br/> i have swf file but without source code and i  want to hide some writings over it<br/> <br/> do any one have any any idea <br/> ???<br/> <br/> can we change the type if swf file to vedio  so we can adjust it in some way ?????????????????????????<br/> <br/> <br/>Sat, 28 Nov 2009 20:58:57 Z2009-11-28T21:55:50Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/2926dbc4-a96a-490b-8418-6f674b9bf1e4http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/2926dbc4-a96a-490b-8418-6f674b9bf1e4Tatworthhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=TatworthIs it better to var than an explicit type?In a function like:<br/> string test = &quot;Hello World&quot;<br/> <br/> string can be replaced by var. This has been advocated as a useful refactor in some quarters --- why?Sat, 28 Nov 2009 21:23:58 Z2009-11-28T21:50:04Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/2197983b-2b5b-4044-9f23-ecebb15a3934http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/2197983b-2b5b-4044-9f23-ecebb15a3934Moksihttp://social.msdn.microsoft.com/Profile/fr-FR/?user=MoksiFolder lock in C#I wanted to create folder lock to apply on some of my folders(to hide their contents)  in such a way that I can lock and open them with a password. I read several articles about folder-lock but  had hard time to understand. Is there anybody that can give me a simple <span style="text-decoration:underline"><strong>code</strong> </span> which can help me to uderstand this issue .... I am using C# 2008 express edition.<br/> <br/> thanks.Sun, 22 Nov 2009 00:55:32 Z2009-11-28T21:35:29Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/15a7bb3e-34c0-41a0-b7f7-48c851f87696http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/15a7bb3e-34c0-41a0-b7f7-48c851f87696raptor6http://social.msdn.microsoft.com/Profile/fr-FR/?user=raptor6Parsing Date to String in queryHi!<br/>Im trying to select from table Date.<br/>I have method DoScalarString.<br/><br/>But if I write: <br/>string CourseStartDate = DBOperations.DoScalarString(&quot;<span style="font-size:x-small"><span style="color:#800000">SELECT StartDate FROM Courses WHERE Title = '&quot;</span>+txt_course_client.Text+<span style="color:#800000"><span style="color:#800000">&quot;'&quot;</span></span>);</span> <br/><br/><br/>I get can't cast DateTime to String<br/><br/><br/>If I try (&quot;Select VALUE CAST (StartDate AS string) FROM.....&quot;),<br/><br/>I get &quot;IErrorInfo.GetDescription failed with E_Fail(0X.....)&quot;<br/><br/>If I do this:<br/><br/><span style="color:#008080;font-size:x-small"><span style="color:#008080;font-size:x-small"><font size=2 color="#008080"><font size=2 color="#008080"> <p>DateTime</p> </font></font></span><font size=2 color="#008080"> <p> </p> </font></span> <p><span style="font-size:x-small"> CourseStartDate = </span><span style="color:#008080;font-size:x-small"><span style="color:#008080;font-size:x-small">DBOperations</span></span><span style="font-size:x-small">.DoScalarDateTime(</span><span style="color:#800000;font-size:x-small"><span style="color:#800000;font-size:x-small">&quot;SELECT StartDate FROM Courses WHERE Title = '&quot;</span></span><span style="font-size:x-small">+txt_course_client.Text+</span><span style="color:#800000;font-size:x-small"><span style="color:#800000;font-size:x-small">&quot;'&quot;</span></span><span style="font-size:x-small">);<font size=2> <p>Folowinf works, but I it needs a whole method additionally. Is there a way to make it like I tried with CAST? Where is there bug?<br/><br/>Thanks!</p> </font></span></p> <p><span style="color:#008080;font-size:x-small"></span></p>Fri, 27 Nov 2009 20:09:32 Z2009-11-28T21:34:57Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/9377a48c-fc92-4c10-adf9-d86f6ef432cdhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/9377a48c-fc92-4c10-adf9-d86f6ef432cdLetsGoNativehttp://social.msdn.microsoft.com/Profile/fr-FR/?user=LetsGoNative? OperatorCan someone explain the following statement to me?<br/><br/><span style="font-size:xx-small"> <p>5 == 1 ? 5</p> </span>Sat, 28 Nov 2009 20:51:42 Z2009-11-28T21:13:00Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/f18d4f80-e3d7-484b-83eb-61cc40f16da7http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/f18d4f80-e3d7-484b-83eb-61cc40f16da7Varun_Devhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=Varun_DevBulk Insert problemHello All<br/><br/>I have been trying to enter multiple records in database . Until now I was trying one by one insertion but I dont think its most efficient way .<br/>What I am doing is : getting all drivers from c:\windows\system32\drivers folder using WMI query.<br/>Here is the code that I am using :<br/><br/> <pre> //Open WMI connection to get Drive info //Build an options object for the connection ConnectionOptions options = new ConnectionOptions(); options.Impersonation = ImpersonationLevel.Impersonate; //Make a connection to a remote computer using these options ManagementScope scope = new ManagementScope(&quot;\\\\&quot; + serverName + &quot;\\root\\cimv2&quot;, options); ObjectQuery driverQuery = new ObjectQuery(&quot;Select * from Win32_SystemDriver where Started='true'&quot;);// ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, driverQuery); ManagementObjectCollection oReturnCollection = searcher.Get(); int count = oReturnCollection.Count; SqlDataAdapter adapter=new SqlDataAdapter(); foreach (ManagementObject driverVar in oReturnCollection) { int driverID = 0; try { collectorConn.Open(); [&quot;PathName&quot;].ToString(); sDriverName = driverVar[&quot;name&quot;].ToString(); sErrorControl = driverVar[&quot;ErrorControl&quot;].ToString(); sStatus = driverVar[&quot;status&quot;].ToString(); sStarted = driverVar[&quot;started&quot;].ToString(); sPathName = driverVar[&quot;PathName&quot;].ToString(); char[] sep = { '\\' }; string[] splitPath = sPathName.Split(sep); int totalSplits = splitPath.Count(); FileVersionInfo fvInfo = null; try { //fvInfo = FileVersionInfo.GetVersionInfo(sPathName); fvInfo = FileVersionInfo.GetVersionInfo(&quot;\\\\&quot; + serverName + &quot;\\C$\\WINDOWS\\system32\\drivers\\&quot; + splitPath[totalSplits-1].ToString()); sDriverVersion = fvInfo.FileVersion.ToString(); } catch { sDriverVersion = &quot;&quot;; } SqlCommand addCmd = new SqlCommand(); addCmd.CommandText = &quot;aut_AddServerDriver&quot;; addCmd.CommandType = CommandType.StoredProcedure; addCmd.Connection = collectorConn; SqlParameter srvidParm = new SqlParameter(&quot;@ServerID&quot;, SqlDbType.Int); srvidParm.Direction = ParameterDirection.Input; srvidParm.Value = serverID; addCmd.Parameters.Add(srvidParm); SqlParameter nameParm = new SqlParameter(&quot;@DriverName&quot;, SqlDbType.VarChar); nameParm.Direction = ParameterDirection.Input; nameParm.Value = checkNull(sDriverName); addCmd.Parameters.Add(nameParm); SqlParameter pathParm = new SqlParameter(&quot;@Path&quot;, SqlDbType.VarChar); pathParm.Direction = ParameterDirection.Input; pathParm.Value = checkNull(sPathName); addCmd.Parameters.Add(pathParm); SqlParameter errorParm = new SqlParameter(&quot;@ErrorControl&quot;, SqlDbType.VarChar); errorParm.Direction = ParameterDirection.Input; errorParm.Value = checkNull(sErrorControl); addCmd.Parameters.Add(errorParm); SqlParameter statusParm = new SqlParameter(&quot;@Status&quot;, SqlDbType.VarChar); statusParm.Direction = ParameterDirection.Input; statusParm.Value = checkNull(sStatus); addCmd.Parameters.Add(statusParm); SqlParameter versionParm = new SqlParameter(&quot;@Version&quot;, SqlDbType.VarChar); versionParm.Direction = ParameterDirection.Input; versionParm.Value = checkNull(sDriverVersion); addCmd.Parameters.Add(versionParm); SqlParameter startedParm = new SqlParameter(&quot;@Started&quot;, SqlDbType.VarChar); startedParm.Direction = ParameterDirection.Input; startedParm.Value = checkNull(sStarted); addCmd.Parameters.Add(startedParm); SqlParameter idParm = new SqlParameter(&quot;@DriverID&quot;, SqlDbType.Int); idParm.Direction = ParameterDirection.Output; addCmd.Parameters.Add(idParm); addCmd.ExecuteNonQuery(); driverID = Convert.ToInt32(addCmd.Parameters[&quot;@DriverID&quot;].Value);</pre> here I am making entry of each driver one by one in database. I was thinking of creating a datatable and making bulkentry of that . Is it good solution. I dont see any improvement.<br/>Here is the changes :<br/><br/> <pre> //Open WMI connection to get Drive info //Build an options object for the connection ConnectionOptions options = new ConnectionOptions(); options.Impersonation = ImpersonationLevel.Impersonate; //Make a connection to a remote computer using these options ManagementScope scope = new ManagementScope(&quot;\\\\&quot; + serverName + &quot;\\root\\cimv2&quot;, options); ObjectQuery driverQuery = new ObjectQuery(&quot;Select * from Win32_SystemDriver where Started='true'&quot;);// ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, driverQuery); ManagementObjectCollection oReturnCollection = searcher.Get(); int count = oReturnCollection.Count; DataTable dt = CreateTable(); SqlDataAdapter adapter=new SqlDataAdapter(); foreach (ManagementObject driverVar in oReturnCollection) { DataRow dr = dt.NewRow(); int driverID = 0; try { collectorConn.Open(); dr[&quot;serverId&quot;] = serverID; dr[&quot;driverName&quot;]=driverVar[&quot;name&quot;].ToString(); dr[&quot;pathName&quot;] = driverVar[&quot;PathName&quot;].ToString(); sPathName = driverVar[&quot;PathName&quot;].ToString(); char[] sep = { '\\' }; string[] splitPath = sPathName.Split(sep); int totalSplits = splitPath.Count(); dr[&quot;ErrorControl&quot;] = driverVar[&quot;ErrorControl&quot;].ToString(); dr[&quot;status&quot;] = driverVar[&quot;status&quot;].ToString(); dr[&quot;started&quot;] = driverVar[&quot;started&quot;].ToString(); FileVersionInfo fvInfo = null; try { //fvInfo = FileVersionInfo.GetVersionInfo(sPathName); fvInfo = FileVersionInfo.GetVersionInfo(&quot;\\\\&quot; + serverName + &quot;\\C$\\WINDOWS\\system32\\drivers\\&quot; + splitPath[totalSplits-1].ToString()); sDriverVersion = fvInfo.FileVersion.ToString(); } catch { sDriverVersion = &quot;&quot;; } dr[&quot;driverVersion&quot;] = sDriverVersion; dt.Rows.Add(dr); } using (SqlBulkCopy copy = new SqlBulkCopy(collectorConn)) { copy.DestinationTableName = &quot;ServerDriver&quot;; copy.WriteToServer(dt); } collectorConn.Close();</pre> Is there any better solution of inserting around 100 records in database using bulcopy or something?<br/><br/>Many thanks for any suggestion!!Fri, 27 Nov 2009 01:03:00 Z2009-11-28T21:05:00Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/8c44089d-39ae-41b3-84f3-02531324e5fehttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/8c44089d-39ae-41b3-84f3-02531324e5feB. Clay Shannonhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=B.%20Clay%20ShannonWhat data method to use when returning multiple rows, assigning to a dataset?I know to retreive one value, you use ExecuteScalar, and to perform an action (such as Update or Insert), you use ExecuteNonQuery. What, though, for a Select statement returning (potentially) multiple rows. For example, assigning the result set to a Dataset?<hr class="sig">Writer / Photographer: www.lulu.com/blackbirdcraven, www.bclayshannon.photoshop.comFri, 27 Nov 2009 22:11:20 Z2009-11-28T20:51:10Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/486d530d-50ff-464c-bcc2-3830a161ad56http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/486d530d-50ff-464c-bcc2-3830a161ad56LetsGoNativehttp://social.msdn.microsoft.com/Profile/fr-FR/?user=LetsGoNativeReflectionHow can I use System.Reflection to see what exactly is going on in a class?Sat, 28 Nov 2009 18:13:32 Z2009-11-28T22:05:48Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/3131401f-e68a-44bd-a3fc-f96460fbd357http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/3131401f-e68a-44bd-a3fc-f96460fbd357SirMoocowhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=SirMoocowNetworkStream.Read() is too slow, pauses after each readI'm trying to receive a file that's about 500KB - more than NetworkStream.Read() can read in one go so I'm looping it, but file transfers take ages... I have a label/progressbar that shows the transfer and I can see it transfers a chunk or so fast, then just stops, waits, then transfers another chunk. I have no idea why it's doing this but it's slowing it down ridiculously.<br/> <br/> Here's my code:<br/> <br/> <pre lang="x-c#">packet = new byte[Client.CData[id].dirSize]; while (bytesRead &lt; Client.CData[id].dirSize) { bytesRead += clientStream.Read(packet, bytesRead, Client.CData[id].dirSize - bytesRead); if (Client.CData[id].fFileManager != null) { Client.CData[id].fFileManager.progressStatus.Text = &quot;Received &quot; + bytesRead.ToString() + &quot; of &quot; + Client.CData[id].dirSize.ToString() + &quot; bytes.&quot;; int percentage = (bytesRead * 100 / Client.CData[id].dirSize); Client.CData[id].fFileManager.progressBar.Value = percentage; } }</pre> CData[id].dirSize is the size of the file overall.<br/> <br/> What am I doing wrong?Fri, 27 Nov 2009 23:12:37 Z2009-11-28T19:06:49Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/2e238caf-4ec4-4874-ad83-8c21c839613chttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/2e238caf-4ec4-4874-ad83-8c21c839613cSoniq2http://social.msdn.microsoft.com/Profile/fr-FR/?user=Soniq2TFTPI need to transfer data from a laptop to target device via TFTP. <div>I can instruct the target device to begin waiting for my data and now need to just begin sending the data from my side.</div> <div>However, I don't see what class is available in C# for me to implement my side of the TFTP transfer.</div> <div><br/></div> <div>Is there such a class in C#?</div> <div><br/></div> <div>Thanks</div> <div><br/></div> <div>-Mike</div>Thu, 26 Nov 2009 19:55:28 Z2009-11-28T18:58:53Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/930e89a9-ac3f-4500-b33d-73a9da89c90fhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/930e89a9-ac3f-4500-b33d-73a9da89c90fHamid Reza Shojaiehttp://social.msdn.microsoft.com/Profile/fr-FR/?user=Hamid%20Reza%20ShojaieBackgroundWorkerHi.<br/>I have a class with a method named  Import() { ... }. This methos is a long time process (reading a database, finding envelopes of some columns and some other computing). In the application main form, I call this method and pass some parameters to it from a void function.<br/>It works perfectly, but when I use the backgroundworker,  this error occured:<br/><br/>Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.<br/><br/>Please help me.Tue, 24 Nov 2009 21:09:56 Z2009-11-28T18:49:07Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/81569b7b-b917-415d-b2c8-773cd7a41c9ehttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/81569b7b-b917-415d-b2c8-773cd7a41c9eAndy C Chttp://social.msdn.microsoft.com/Profile/fr-FR/?user=Andy%20C%20CDelegates and References to classesHi<br/> <br/> If I have the following code:<br/> <br/> <div style="color:Black;background-color:White"> <pre><span style="color:Blue">class</span> A { <br/> <span style="color:Blue">public</span> A(Action&lt;<span style="color:Blue">int</span> &gt; myDelegate) { MyDelegate = myDelegate; } Action&lt;<span style="color:Blue">int</span> &gt; MyDelegate {<span style="color:Blue">get</span> ; <span style="color:Blue">private</span> s<span style="color:Blue">et</span> ;} } <span style="color:Blue"><br/> class</span> B { <br/> <span style="color:Blue">public</span> B(Action&lt;<span style="color:Blue">int</span> &gt; myDelegate) { MyDelegate = myDelegate; } Action&lt;<span style="color:Blue">int</span> &gt; MyDelegate {<span style="color:Blue">get</span> ; <span style="color:Blue">private</span> <span style="color:Blue">set</span> ;} }</pre> </div> <br/> If I do:<br/> <br/> <div style="color:Black;background-color:White"> <pre> Action&lt;<span style="color:Blue">int</span> &gt; action = i =&gt; DoSomething(i); A = <span style="color:Blue">new</span> A(action); B = <span style="color:Blue">new</span> B(A.MyDelegate); </pre> </div> <br/> Will the class B be created with the reference to the underlying delegate or will it keep a reference to class A? As if it keeps a reference to class A and I want class A to be garbage collected it could create a memory leak as long as B is alive.<br/> <br/> Thank youSat, 28 Nov 2009 18:39:12 Z2009-11-28T18:39:13Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/b0d45d3b-e364-4166-8cf1-2534ef66ccb0http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/b0d45d3b-e364-4166-8cf1-2534ef66ccb0MDMourahttp://social.msdn.microsoft.com/Profile/fr-FR/?user=MDMouraBase64 and Byte ConversionHello,<br/> <br/> I have the following:<br/> String result = Convert.ToBase64String(Encoding.UTF8.GetBytes(&quot;Test&quot;));<br/> <br/> Shouldn't result become &quot;Test&quot;? I get &quot;VGVzdA==&quot;<br/> <br/> I am using this approach to save Byte data into a XML file and get it back to a string.<br/> It isn't working so I made this test and I was expecting to get &quot;Test&quot; in result.<br/> <br/> Thanks,<br/> Miguel<br/>Sat, 28 Nov 2009 02:11:44 Z2009-11-28T18:37:38Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/60ac26df-a6d0-47fc-ac1e-30f431dc8f6chttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/60ac26df-a6d0-47fc-ac1e-30f431dc8f6ccode_warriorhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=code_warriorHow to i Converty Object to Image?hi Friend, <br/><br/><br/>I need to convert an Object to Image type, but in which namespace / reference type &quot;Image&quot; resides?<br/><br/>thanksSat, 28 Nov 2009 17:19:13 Z2009-11-28T17:54:51Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/0e9d931a-fb35-44ca-bd60-adac003b82d9http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/0e9d931a-fb35-44ca-bd60-adac003b82d9jal2http://social.msdn.microsoft.com/Profile/fr-FR/?user=jal2Late-Binding problem I'm trying to convert the following VB.Net code to C#<br/> <br/> <br/> Dim DB As DAO.Database = New DAO.DBEngine().OpenDatabase(&quot;C:\Northwind.mdb&quot;)<br/>         Dim td As DAO.TableDef = DB.TableDefs(&quot;Customers&quot;)<br/>         For Each idx As DAO.Index In td.Indexes<br/>             If idx.Primary Then<br/>                 For i As Int32 = 0 To idx.Fields.Count - 1<br/>                     MsgBox(idx.Fields(i).Name)<br/>                 Next<br/>             End If<br/>         Next<br/> <br/> The problem is in the line <br/> .......For i As Int32 = 0 To idx.Fields.Count - 1<br/> The property &quot;Count&quot; doesn't show up in Intellisense  (neither in VB.Net or C#). In fact you can't even write, in C#,<br/> ......MsgBox(idx.Fields(i).Name)<br/> because &quot;Fields&quot; shows up as a single object, not as an array or collection of fields.  Yet in VB.Net I can get away with all this, apparently because it does late-binding automatically. In C# I tried the following (to at least access the &quot;Count&quot; value even though this still falls short of accessing the &quot;Name&quot; value):<br/> <br/>  DAO.TableDef TD = CurrentDB.TableDefs[oTab.Table];<br/>             foreach (DAO.Index idx in TD.Indexes)<br/>                 if (idx.Primary)<br/>                 {<br/>                     Type oType = idx.Fields.GetType();<br/>                     System.Reflection.PropertyInfo pi = oType.GetProperty(&quot;Count&quot;);<br/>                     int Count = (int)pi.GetValue(idx.Fields, null);<br/>                 }<br/> <br/> But &quot;pi&quot; comes out &quot;null&quot;. So I can't even get the Count value, much less the Name values (which is what I really need). Any ideas? (If you want to try this yourself, please add a reference to Microsoft DAO 3.6 Object Library).  Thanks for any help !<br/>Sat, 28 Nov 2009 15:51:07 Z2009-11-28T17:53:29Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/dad8f9e8-dcf3-46d6-9640-63cd5b7c2eb7http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/dad8f9e8-dcf3-46d6-9640-63cd5b7c2eb7code_warriorhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=code_warriorHow to convert an object to byte[ ]?Hi Friend, <br/><br/>I dont think i;ve written the thread in an understandable way....actually i need to convert a value in a datarow cell that of type varbinary(in DB) to byte[]?<br/><br/><br/>thanksSat, 28 Nov 2009 15:50:37 Z2009-11-28T16:57:56Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/9f2d7e8e-4dc0-46a0-a720-b8e74d508285http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/9f2d7e8e-4dc0-46a0-a720-b8e74d508285neetu singh 123http://social.msdn.microsoft.com/Profile/fr-FR/?user=neetu%20singh%20123C#how we can write a program for drawing pyramid using for loop in c sharp?<br/>Sat, 28 Nov 2009 16:07:44 Z2009-11-28T16:24:07Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/d5620fc7-6fbf-48e0-9140-3914747221c0http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/d5620fc7-6fbf-48e0-9140-3914747221c0Boki_thegamehttp://social.msdn.microsoft.com/Profile/fr-FR/?user=Boki_thegameFrom picturebox to databaseHow to put image from picturebox to database using Linq???<br/> <br/> ThanksSat, 28 Nov 2009 01:17:53 Z2009-11-28T16:21:01Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/128aa763-2c40-4eb5-b253-5d7cab0b93a4http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/128aa763-2c40-4eb5-b253-5d7cab0b93a4hazzhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=hazzA socket is disposed of in a Timeout and I get an error in ReceiveCallBack() trying to access..<p>Hightlighted in large purple font below are the two lines where the following errors occur and this order;<br/>1.    int bytesRead = client.EndReceive(ar);         in ReceiveCallBack()  and<br/>2.    client.Shutdown(SocketShutdown.Both);       in DeviceCommunicationTimeOut</p> <p><br/>I can see that the TimeOut, after 125 milliseconds, is closing the socket and then when there is an  unsuccessful attempt to access the socket in the ReceiveCallBack().  But I haven't figured out how to prevent that. Thank you so much for any help on my first asynchronous socket app.</p> <div style="color:black;background-color:white"> <div style="color:black;background-color:white"> <div style="color:black;background-color:white"> <pre><span style="color:blue">public</span> <span style="color:blue">class</span> StateObject { <span style="color:blue">public</span> Socket workSocket = <span style="color:blue">null</span>; <span style="color:blue">public</span> <span style="color:blue">const</span> <span style="color:blue">int</span> BufferSizeForReceive = 2400; <span style="color:blue">public</span> <span style="color:blue">byte</span>[] buffer = <span style="color:blue">new</span> <span style="color:blue">byte</span>[BufferSizeForReceive]; <span style="color:blue">public</span> StringBuilder sb = <span style="color:blue">new</span> StringBuilder(); <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">byte</span>[] toSocket; } <span style="color:blue">public</span> <span style="color:blue">partial</span> <span style="color:blue">class</span> Form1 : Form { <span style="color:blue">private</span> <span style="color:blue">static</span> System.Threading.Timer timerForTimeOut = <span style="color:blue">null</span>; <span style="color:green">//one shot </span> <span style="color:blue">private</span> <span style="color:blue">static</span> Object syncObj = <span style="color:blue">new</span> Object(); <span style="color:green">//Lock when receiving data or TimeOut called</span> <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">private</span> <span style="color:blue">static</span> <span style="color:blue">byte</span>[] toSocket; <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">string</span> response; <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">string</span> softwareVersionFromDevice; <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">string</span> host = <span style="color:#a31515">&quot;10.0.110.35&quot;</span>; <span style="color:blue">private</span> <span style="color:blue">static</span> Int32 port = 50000; <span style="color:blue">public</span> Form1() { InitializeComponent(); toSocket = <span style="color:blue">new</span> <span style="color:blue">byte</span>[7]; toSocket[0] = 2; <span style="color:green">//msgID</span> toSocket[1] = 0; <span style="color:green">//status</span> toSocket[2] = 0; <span style="color:green">//data lehgth</span> toSocket[3] = 0; toSocket[4] = 0; <span style="color:green">//seq #</span> toSocket[5] = 1; } <span style="color:blue">private</span> <span style="color:blue">void</span> button1_Click(<span style="color:blue">object</span> sender, EventArgs e) { BeginConnect(host, port); } <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) { <span style="color:blue">try</span> { Socket s = <span style="color:blue">new</span> Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); connectDone.Reset(); s.BeginConnect(host, port, <span style="color:blue">new</span> AsyncCallback(ConnectCallback), s); connectDone.WaitOne(); } <span style="color:blue">catch</span> (Exception ex) { Console.Write(<span style="color:#a31515">&quot;BeginConnect exception = &quot;</span> + ex.ToString()); } } <span style="color:blue">public</span> <span style="color:blue">static</span> <span style="color:blue">void</span> ConnectCallback(IAsyncResult ar) { <span style="color:blue">try</span> { Socket client = (Socket)ar.AsyncState; client.EndConnect(ar); connectDone.Set(); <span style="color:green">// create a one-shot timer</span> <span style="color:blue">if</span> (timerForTimeOut == <span style="color:blue">null</span>) timerForTimeOut = <span style="color:blue">new</span> System.Threading.Timer(DeviceCommunicationTimeOut, client, 125, 125); Send(client); } <span style="color:blue">catch</span> (Exception ex) { Console.Write(<span style="color:#a31515">&quot;ConnectCallback exception = &quot;</span> + ex.ToString()); } } <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">void</span> DeviceCommunicationTimeOut(<span style="color:blue">object</span> state) { <span style="color:blue">try</span> { Socket client = (Socket)state; <span style="color:blue">lock</span> (syncObj) { <span style="color:green">// timed out. close and shutdown socket</span> <span style="font-size:medium;color:#800080"> client.Shutdown(SocketShutdown.Both); </span> client.Close(); } } <span style="color:blue">catch</span> (Exception ex) { Console.Write(<span style="color:#a31515">&quot;DeviceCommunicationTimeOut exception = &quot;</span> + ex.ToString()); } } <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">void</span> Send(Socket client) { <span style="color:blue">try</span> { client.BeginSend(toSocket, 0, toSocket.Length, SocketFlags.None, <span style="color:blue">new</span> AsyncCallback(SendCallback), client); } <span style="color:blue">catch</span> (Exception ex) { Console.Write(<span style="color:#a31515">&quot;Send exception = &quot;</span> + ex.ToString()); } } <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">void</span> SendCallback(IAsyncResult ar) { Socket client = (Socket)ar.AsyncState; <span style="color:blue">int</span> bytesSent = client.EndSend(ar); sendDone.Set(); Receive(client); } <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">void</span> Receive(Socket client) { <span style="color:blue">try</span> { StateObject state = <span style="color:blue">new</span> StateObject(); state.workSocket = client; client.BeginReceive(state.buffer, 0, StateObject.BufferSizeForReceive, 0, <span style="color:blue">new</span> AsyncCallback(ReceiveCallback), state); } <span style="color:blue">catch</span> (Exception ex) { Console.Write(<span style="color:#a31515">&quot;Receive exception = &quot;</span> + ex.ToString()); } } <span style="color:blue">private</span> <span style="color:blue">static</span> <span style="color:blue">void</span> ReceiveCallback(IAsyncResult ar) { <span style="color:blue">try</span> { <span style="color:blue">lock</span> (syncObj) { timerForTimeOut.Change(125, 10000); <span style="color:green">// Timeout.Infinite</span> } StateObject state = (StateObject)ar.AsyncState; Socket client = state.workSocket; <span style="color:blue">int</span> <span style="font-size:medium;color:#800080"> bytesRead = client.EndReceive(ar); </span> <span style="color:blue">if</span> (bytesRead &gt; 0) { state.sb.Append(Encoding.ASCII.GetString(state.buffer, 0, bytesRead)); client.BeginReceive(state.buffer, 0, StateObject.BufferSizeForReceive, 0, <span style="color:blue">new</span> AsyncCallback(ReceiveCallback), state); } <span style="color:blue">else</span> { <span style="color:blue">if</span> (state.sb.Length &gt; 1) { response = state.sb.ToString(); } receiveDone.Set(); } } <span style="color:blue">catch</span> (ObjectDisposedException ex) { Console.WriteLine(<span style="color:#a31515">&quot;EndReceive exception = &quot;</span> + ex.ToString()); } } } </pre> </div> </div> </div>Mon, 23 Nov 2009 21:55:26 Z2009-11-28T15:57:32Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/483ad983-c1dd-4e01-9ebc-b171b3018dd4http://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/483ad983-c1dd-4e01-9ebc-b171b3018dd4Scionwesthttp://social.msdn.microsoft.com/Profile/fr-FR/?user=ScionwestChanging an inherited properties Attribute valueGreetings,<br/> <br/> I currently have a class that inherits from a base class. The base class has a property called Name with a DefaultValueAttribute attached to it. I need to be able to change the DefaultValueAttribute on my child class, without re-declaring the property. Something to this affect...<br/> <br/> Psuedo code:<br/> <pre>class Character { [DefaultValueAttribute(&quot;New Character&quot;)] string name } class NPC { NPC() { //Change DefaultValueAttribute here to New NPC instead of New Character } }</pre> Thanks for any tips<hr class="sig">Free iPhone ringtone conversion utility. (iringtones.codeplex.com) Follow me on Twitter: Scionwest follow my blog: Scionwest.blogspot.com Developing a managed scripting engine (ManagedScripting.com)Thu, 26 Nov 2009 03:06:18 Z2009-11-28T15:37:02Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/a93e15a9-311e-4889-ab5f-f84c5d100c3bhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/a93e15a9-311e-4889-ab5f-f84c5d100c3bharsh_1988http://social.msdn.microsoft.com/Profile/fr-FR/?user=harsh_1988color change in rich text boxi want to change the color of the text written in rich text box ......i tried this but it does not work<br/> pls help<br/> code snippet is given below:<br/> <br/> Color cc = Color.FromArgb(255, 5, 5);<br/>                 richTextBox1.SelectionColor = cc;Fri, 27 Nov 2009 16:07:44 Z2009-11-28T15:34:02Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/ed13d9e9-6bf5-4210-83de-0504bfca43aehttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/ed13d9e9-6bf5-4210-83de-0504bfca43aepawelmhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=pawelmHow to check and correct text in dataViewGrid cells<p>Hello. I have a problem.<br/>I want to check what user writes into first column cells. I want to check it in CellLeave event<br/><br/>i've write some code but it doesn't do what i want. When I leave cell nothing happens, i need to click on this cell again and leave it again. I'd like to make simple check. An user types into cell a file extension and if it's written without *. at he begining my code should add this signs to this extension<br/><br/>My code:</p> <div style="background-color:white;color:black"> <pre> <span style="color:blue">private</span> <span style="color:blue">void</span> dataGridView1_CellLeave(<span style="color:blue">object</span> sender, DataGridViewCellEventArgs e) { <span style="color:blue">try</span> { <span style="color:blue">string</span> content; <span style="color:blue">if</span> (System.Convert.ToString(dataGridView1[dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex].Value) != <span style="color:#a31515">&quot;&quot;</span>) { content = System.Convert.ToString(dataGridView1[dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex].Value); <span style="color:blue">if</span> (e.ColumnIndex == 0) { <span style="color:blue">if</span> (content[0] != <span style="color:#a31515">'*'</span>) dataGridView1[dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex].Value = content.Insert(0, <span style="color:#a31515">&quot;*&quot;</span>); <span style="color:blue">if</span> (content[1] != <span style="color:#a31515">'.'</span>) dataGridView1[dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex].Value = content.Insert(1, <span style="color:#a31515">&quot;.&quot;</span>); } } } <span style="color:blue">catch</span> (Exception ex) { MessageBox.Show(ex.Message); } } </pre> </div>Thu, 26 Nov 2009 19:51:26 Z2009-11-28T15:18:43Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/8ec26877-9b75-4649-83d7-047005e8012ehttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/8ec26877-9b75-4649-83d7-047005e8012eMitja Boncahttp://social.msdn.microsoft.com/Profile/fr-FR/?user=Mitja%20BoncaDesktop shortcut<span style="font-family:'Times New Roman';font-size:medium"> <div style="color:#000000;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:67%;background-image:initial;background-repeat:initial;background-attachment:initial;background-color:#ffffff;margin:8px">How to create a shortcut on the user`s desktop, while application is being installed?</div> <div style="color:#000000;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:67%;background-image:initial;background-repeat:initial;background-attachment:initial;background-color:#ffffff;margin:8px">What do I need to do in the Setup Project?</div> <div style="color:#000000;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:67%;background-image:initial;background-repeat:initial;background-attachment:initial;background-color:#ffffff;margin:8px"><br/></div> <div style="color:#000000;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:67%;background-image:initial;background-repeat:initial;background-attachment:initial;background-color:#ffffff;margin:8px">This is what I did, but there is no Icon on the desktop:</div> <img src="http://www.file.si/files/4quxoqxqfgibe65g2frl.jpg" alt=""> </span>Fri, 27 Nov 2009 22:07:33 Z2009-11-28T14:53:14Zhttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/dd01934b-7e3f-4e1a-9986-da99ec48e13ehttp://social.msdn.microsoft.com/Forums/fr-FR/csharpgeneral/thread/dd01934b-7e3f-4e1a-9986-da99ec48e13eIamHuMhttp://social.msdn.microsoft.com/Profile/fr-FR/?user=IamHuMInstall custom font/cursors with the application...<p>hi...</p> <p>In my application i need some custom fonts &amp; cursors to be used. How i can check if the corrosponding font is installed or not...?<br/>If the font is not installed then how to install the font and cursor.<br/>Is there any sample document/code to explain this...? <br/>I am using VS2005 .Net2.0.</p> <p>Thanks in advance,<br/>IamHuM</p>Sat, 28 Nov 2009 12:31:26 Z2009-11-28T14:40:53Z