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. Tutti i diritti riservati.Sat, 28 Nov 2009 17:24:21 Z24becc9b-b984-47b2-a748-a62e38c0066fhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/60ac26df-a6d0-47fc-ac1e-30f431dc8f6chttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/60ac26df-a6d0-47fc-ac1e-30f431dc8f6ccode_warriorhttp://social.msdn.microsoft.com/Profile/it-IT/?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:24:20Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/73af0cb4-3cd9-456f-844b-c05eeaae43c0http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/73af0cb4-3cd9-456f-844b-c05eeaae43c0Sri096http://social.msdn.microsoft.com/Profile/it-IT/?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-28T16:56:57Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/0e9d931a-fb35-44ca-bd60-adac003b82d9http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/0e9d931a-fb35-44ca-bd60-adac003b82d9jal2http://social.msdn.microsoft.com/Profile/it-IT/?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-28T16:48:54Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/dad8f9e8-dcf3-46d6-9640-63cd5b7c2eb7http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/dad8f9e8-dcf3-46d6-9640-63cd5b7c2eb7code_warriorhttp://social.msdn.microsoft.com/Profile/it-IT/?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/it-IT/csharpgeneral/thread/9f2d7e8e-4dc0-46a0-a720-b8e74d508285http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/9f2d7e8e-4dc0-46a0-a720-b8e74d508285neetu singh 123http://social.msdn.microsoft.com/Profile/it-IT/?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/it-IT/csharpgeneral/thread/d5620fc7-6fbf-48e0-9140-3914747221c0http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/d5620fc7-6fbf-48e0-9140-3914747221c0Boki_thegamehttp://social.msdn.microsoft.com/Profile/it-IT/?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/it-IT/csharpgeneral/thread/128aa763-2c40-4eb5-b253-5d7cab0b93a4http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/128aa763-2c40-4eb5-b253-5d7cab0b93a4hazzhttp://social.msdn.microsoft.com/Profile/it-IT/?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/it-IT/csharpgeneral/thread/483ad983-c1dd-4e01-9ebc-b171b3018dd4http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/483ad983-c1dd-4e01-9ebc-b171b3018dd4Scionwesthttp://social.msdn.microsoft.com/Profile/it-IT/?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/it-IT/csharpgeneral/thread/a93e15a9-311e-4889-ab5f-f84c5d100c3bhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/a93e15a9-311e-4889-ab5f-f84c5d100c3bharsh_1988http://social.msdn.microsoft.com/Profile/it-IT/?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/it-IT/csharpgeneral/thread/ed13d9e9-6bf5-4210-83de-0504bfca43aehttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/ed13d9e9-6bf5-4210-83de-0504bfca43aepawelmhttp://social.msdn.microsoft.com/Profile/it-IT/?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/it-IT/csharpgeneral/thread/8ec26877-9b75-4649-83d7-047005e8012ehttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/8ec26877-9b75-4649-83d7-047005e8012eMitja Boncahttp://social.msdn.microsoft.com/Profile/it-IT/?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/it-IT/csharpgeneral/thread/dd01934b-7e3f-4e1a-9986-da99ec48e13ehttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/dd01934b-7e3f-4e1a-9986-da99ec48e13eIamHuMhttp://social.msdn.microsoft.com/Profile/it-IT/?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:53Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/3131401f-e68a-44bd-a3fc-f96460fbd357http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/3131401f-e68a-44bd-a3fc-f96460fbd357SirMoocowhttp://social.msdn.microsoft.com/Profile/it-IT/?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-28T14:33:52Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/d511f625-f0eb-46c6-8b41-5e8cb5ef2ed0http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/d511f625-f0eb-46c6-8b41-5e8cb5ef2ed0vipinbakayahttp://social.msdn.microsoft.com/Profile/it-IT/?user=vipinbakayahow to atart with c#how to write code in c#Sat, 28 Nov 2009 12:35:16 Z2009-11-28T14:29:00Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/41716995-9320-4925-a66b-80f9c313a283http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/41716995-9320-4925-a66b-80f9c313a283alainkkkhttp://social.msdn.microsoft.com/Profile/it-IT/?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-28T13:31:21Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/599adb6e-f1ad-4409-be24-2fd85cbe185dhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/599adb6e-f1ad-4409-be24-2fd85cbe185dNerathashttp://social.msdn.microsoft.com/Profile/it-IT/?user=NerathasForm Button code problemHello,<br/>I have made  working console version now i wish to make the same program as a windows form application.<br/>The problem lies in the code i have to put in  btnBereken (the button i click on the form) that should display the following result:<br/><em>In het interval [5000, 9000] is de wonderlijke rij het langst voor het getal 6171: lengte 262.<br/><br/></em>For this i have made a label called &quot;lblresult&quot; wich is on the bottom of my form, so it will display the above message at the bottom of the program.<br/>I have tried writing the code but i keep getting stuck in the part where i have to to write the code in the button itself. Wich is written below and generates 2 errors : <strong><em><span style="text-decoration:underline">&quot;No overload for method 'L' takes '1' arguements </span></em></strong>(Also what does this error mean exactly?, Thanks in advance)<br/> <p><strong>lblresult.Text = <span style="color:#a31515">&quot;In het interval [&quot;</span> + n + <span style="color:#a31515">&quot;, &quot;</span> + p + <span style="color:#a31515">&quot;] is de wonderlijke rij het langst voor het getal&quot;</span> + Val.L(LangsteGetal) +<span style="color:#a31515">&quot;: lengte&quot;</span> + Val.L(LengteLGetal) + <span style="color:#a31515">&quot;.&quot;</span>;<br/></strong></p> <br/><br/> <pre lang="x-c#">using System; using System.Windows.Forms; namespace Opg { public partial class FrmMain : Form { public FrmMain() { InitializeComponent(); } private void txtboxondergrens_TextChanged(object sender, EventArgs e) { lblresult.Text = &quot;&quot;; } private void txtboxbovengrens_TextChanged(object sender, EventArgs e) { lblresult.Text = &quot;&quot;; } private void btnBereken_Click(object sender, EventArgs e) { ClsWonderlijkeRij WR = new ClsWonderlijkeRij(); ClsInterval Val = new ClsInterval(); ushort n = ushort.Parse(txtondergrens.Text); ushort p = ushort.Parse(txtbovengrens.Text); ulong LangsteGetal = ulong.Parse(lblresult.Text); ushort LengteLGetal = ushort.Parse(lblresult.Text); <strong>lblresult.Text = &quot;In het interval [&quot; + n + &quot;, &quot; + p + &quot;] is de wonderlijke rij het langst voor het getal&quot; + Val.L(LangsteGetal) + &quot;: lengte&quot; + Val.L(LengteLGetal) + &quot;.&quot;;</strong> } } }</pre> <br/><br/><br/> <pre lang="x-c#">using System; namespace Opg { public class ClsInterval { ClsWonderlijkeRij WR = new ClsWonderlijkeRij(); public void L(ulong Ondergrens, ulong Bovengrens, out ulong LangsteGetal, out ushort LengteLGetal) { LangsteWonRij(Ondergrens, Bovengrens, out LangsteGetal, out LengteLGetal); } private void LangsteWonRij(ulong Ondergrens, ulong Bovengrens, out ulong LangsteGetal, out ushort LengteLGetal) { LangsteGetal = 0; LengteLGetal = 0; for (ulong i = Ondergrens; i &lt;= Bovengrens; i++) { ushort lengte = WR.LengteWonderlijkeRij(i); if (lengte &gt; LengteLGetal) { LengteLGetal = lengte; LangsteGetal = i; } } } } } </pre> <br/><br/><br/>Sat, 28 Nov 2009 10:44:19 Z2009-11-28T13:24:43Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/5876114f-0a71-4e4b-82b8-353c373994aehttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/5876114f-0a71-4e4b-82b8-353c373994aecode_warriorhttp://social.msdn.microsoft.com/Profile/it-IT/?user=code_warriorI need to store a photo as binary, what type the field shold be?<p>Hi friend, <br/><br/>In my DB i need to store the photo as a binary object so i've add a column of type &quot;varbinary&quot;</p> <p>in my class i have a field called PhotoObject that should hold the photo, what its type shuould be is it as a byte[]</p> <p>byte[] PhotoObject {get; set;}</p> <p>thanks</p> <p> </p> <p> </p> <p> </p>Sat, 28 Nov 2009 12:55:06 Z2009-11-28T13:10:55Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/c2f54112-5122-4e2a-9dab-f8888c59f209http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/c2f54112-5122-4e2a-9dab-f8888c59f209MITTALPAhttp://social.msdn.microsoft.com/Profile/it-IT/?user=MITTALPAprivate methods using .net reflection. why??Hi<br/> <br/> I used reflection many times before on public methods but never realized that private methods can be invoked too. See the link :<a title=link href="http://www.codingday.com/reflection-with-private-members/" title=link>http://www.codingday.com/reflection-with-private-members/</a> <br/> <br/> I am still thinking why is that allowed in the first place? <br/> Isn't that going to break the rule of &quot;private&quot; being &quot;private&quot;?<br/> <br/> puzzled<br/> AJSat, 28 Nov 2009 06:16:49 Z2009-11-28T12:19:06Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/12e29fac-f093-47d7-a80b-04b93d27f00chttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/12e29fac-f093-47d7-a80b-04b93d27f00cMadan Kumar Rajanhttp://social.msdn.microsoft.com/Profile/it-IT/?user=Madan%20Kumar%20RajanSystem boot resistant programsHello all, <div><br/></div> <div>I have  few softwares that on installation will ask for system reboot. I have decided to put all the softwares into an ISO image along with an installer. Right now I am coding for that installer only. The installer asks users to choose which one to install from the list of available s/w.</div> <div><br/></div> <div>The problem right now is, if one of the installations does a system reboot, I need to launch the installer automatically so as to continue with the other installations. So here are the questions -</div> <div>1. How should I write code for the installer so that it automatically starts even if one of the installations reboots the system?</div> <div>2. How should I retain the state of the previous installations I have done? (ie. If I have 3 setups to be installed A,B,C. If A is already installed, B is currently being installed and has triggered a reboot, and C is yet to be installed. I should not ask the user to install A once again as it has been done already.) Also assume that I have no way to interact with A, B, C as they are already packaged and the code cant be modified.</div> <div><br/></div> <div>I am new to C# and dotnet. So I need your help very badly.</div> <div><br/></div> <div>Thanks,</div> <div>Madan</div>Wed, 11 Nov 2009 05:32:52 Z2009-11-28T12:04:55Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/405c2e0c-5904-4a8e-b920-4a846a82c00chttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/405c2e0c-5904-4a8e-b920-4a846a82c00csitnchttp://social.msdn.microsoft.com/Profile/it-IT/?user=sitncHow to deal with Outlook COM exception when program with Outlook.dll?Hi,<br/> <br/> In my program, I use Outlook.dll COM interface to query email and PIM data of local Outlook. But sometimes, Outlook.dll COM throw exception. They are like below information.<br/> <br/> &quot;System.Runtime.InteropServices.COMException (0x98B04005)&quot;<br/> <br/> When the exceptio is thrown, the opertion for Outlook will be failed. <br/> How can I solve the issue?<br/> <br/> Thanks,<br/> William LiuWed, 19 Aug 2009 03:42:21 Z2009-11-28T11:54:14Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/4d661245-ddbc-492b-94d5-b4bdcb259c4ehttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/4d661245-ddbc-492b-94d5-b4bdcb259c4ecode_warriorhttp://social.msdn.microsoft.com/Profile/it-IT/?user=code_warriorWould it be a good programming practise to retreive data from all tables at once in a seach event?<p>Hi friends,</p> <p>currently i'm developing a Application management system that keep a track of all records. A record (an applicant) searched by Applicant Index. <br/>IN my application the followng criteria must be fetch at search: <br/><br/>Applicant Details<br/>Contact details<br/>Persona<br/>Acedemics<br/>Professional Certifications<br/>Hobbies<br/>Referees<br/><br/>Each criteria maps to their tables in DB<br/><br/>I've added tabs for each criteria. <br/><br/>THis is kind of a quesiton that shows lazyness however, would it be a good programming practise to return all criteria when the user hits search or shold i make the application first search Application details when the user hits search then when the user click on a tab the of criteria should be fetched from DB thus make my life easier with the SQL part becuase if i fecth all crieteria at once i have to write a join statement that links 7 tbalse....?<br/><br/>Thanks</p>Sat, 28 Nov 2009 10:49:14 Z2009-11-28T11:13:44Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/56bde1b0-4619-42ec-a473-a51febef9febhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/56bde1b0-4619-42ec-a473-a51febef9febMartienoShttp://social.msdn.microsoft.com/Profile/it-IT/?user=MartienoSWindow (Form) loading takes 2 minutes and when its loaded everythings loaded..Hello,<br/> <br/> Im trieng to runn a program i build my self, but it just takes lots of loading time (10 secs i guess) then it shows up and all the progresses are done..<br/> This is not suppose too happen. What i want it to do is show the form then do the progress part, so i can see what it is doing.<br/> <br/> <pre>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net; using System.IO; using System.Xml; using System.Xml.Linq; using System.Data.OleDb; using System.Data.Common; namespace Nettoprijs { public partial class Nettoprijs : Form { public Nettoprijs() { InitializeComponent(); } private void Nettoprijs_Load(object sender, EventArgs e) { string xpath = @&quot;soap/GeneratePriceList.xml&quot;; string xreadText = File.ReadAllText(xpath); DownloadXML(xreadText, &quot;pricelist.xml&quot;, &quot;*sample*&quot;, &quot;*sample*&quot;); listBox2.Items.Add(&quot;- Total found.. (&quot; + getTotalProductCounts(&quot;pricelist.xml&quot;) + &quot;)&quot;); toolStripProgressBar1.Minimum = 0; toolStripProgressBar1.Maximum = getTotalProductCounts(&quot;pricelist.xml&quot;); toolStripProgressBar1.Step = 1; itemsVerwerken(&quot;pricelist.xml&quot;); } public void DownloadXML(string soapRequest, string File, string soapAction, string cdrURL) { listBox2.Items.Add(&quot;- Downloading.. (&quot; + File + &quot;)&quot;); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(cdrURL); req.ContentType = &quot;text/xml; charset=utf-8&quot;; req.Accept = &quot;text/xml&quot;; req.Method = &quot;POST&quot;; req.Headers.Add(&quot;SOAPAction&quot;, soapAction); req.KeepAlive = false; XmlDocument doc = new XmlDocument(); doc.LoadXml(soapRequest); using (Stream strm = req.GetRequestStream()) { doc.Save(strm); } HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); using (Stream respStm = resp.GetResponseStream()) { using (StreamReader r = new StreamReader(respStm)) { string str = r.ReadToEnd(); FileInfo f = new FileInfo(File); StreamWriter w = f.CreateText(); w.Write(str); w.Close(); listBox2.Items.Add(&quot;- Saved.. (&quot; + File + &quot;)&quot;); } } } public int getTotalProductCounts(string File) { string LastRefresh = XElement.Load(File).Descendants(&quot;Products&quot;).First().Attribute(&quot;LastRefresh&quot;).Value; LastRefresh = LastRefresh.Replace(&quot;'&quot;, &quot;\\'&quot;); int i = 0; foreach (XElement item in XElement.Load(File).Descendants(&quot;Product&quot;)) { i++; } return i; } public int itemsVerwerken(string File) { string LastRefresh = XElement.Load(File).Descendants(&quot;Products&quot;).First().Attribute(&quot;LastRefresh&quot;).Value; LastRefresh = LastRefresh.Replace(&quot;'&quot;, &quot;\\'&quot;); int i = 0; foreach (XElement item in XElement.Load(File).Descendants(&quot;Product&quot;)) { string ID = item.Attribute(&quot;ID&quot;).Value; ID = CleanInput(ID); string ManufacturerID = item.Attribute(&quot;ManufacturerID&quot;).Value; ManufacturerID = CleanInput(ManufacturerID); string EAN = item.Attribute(&quot;EAN&quot;).Value; EAN = CleanInput(EAN); string Description = item.Descendants(&quot;Description&quot;).First().Value; Description = CleanInput(Description); string Description2 = item.Descendants(&quot;Description2&quot;).First().Value; Description2 = CleanInput(Description2); string VatRate = item.Descendants(&quot;VatRate&quot;).First().Value; VatRate = CleanInput(VatRate); string QuantityOnHand = item.Descendants(&quot;QuantityOnHand&quot;).First().Value; QuantityOnHand = CleanInput(QuantityOnHand); string StockLevel = item.Descendants(&quot;StockLevel&quot;).First().Value; StockLevel = CleanInput(StockLevel); string Status = item.Descendants(&quot;Status&quot;).First().Value; Status = CleanInput(Status); string Brand = item.Descendants(&quot;Brand&quot;).First().Value; Brand = CleanInput(Brand); string UnitPrice = item.Descendants(&quot;UnitPrice&quot;).First().Value; UnitPrice = CleanInput(UnitPrice); listBox1.Items.Add(&quot;- Set.. (&quot; + ID + &quot;)&quot;); toolStripProgressBar1.PerformStep(); } return i; } public string CleanInput(string input) { string val = input.Replace((char)96, '\'').Replace( (char)8216, '\'').Replace((char)8217, '\'').Replace( (char)8242, '\'').Replace((char)769, '\'').Replace( (char)768, '\'').Replace((char)8220, '&quot;').Replace( (char)8221, '&quot;').Replace((char)8243, '&quot;').Replace( (char)12291, '&quot;').Replace((char)8208, '-').Replace( (char)8211, '-').Replace((char)8212, '-').Replace( (char)8722, '-').Replace((char)173, '-').Replace( (char)8209, '-').Replace((char)8259, '-').Replace( (char)160, ' ').Replace((char)8195, ' ').Replace( (char)8194, ' '); return val.Replace(&quot;'&quot;, &quot;\\'&quot;); } } } </pre>Fri, 27 Nov 2009 00:57:29 Z2009-11-28T10:18:50Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/2793dd17-bb51-4af4-ac3d-3173da483af5http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/2793dd17-bb51-4af4-ac3d-3173da483af5Sunil Sachdevahttp://social.msdn.microsoft.com/Profile/it-IT/?user=Sunil%20SachdevaHaving problem in Microsoft Outlook Automation<p>hi guys,</p> <p>             I am working on a windows service in which i'm trying to automate outlook to send emails  periodically based on some criteria.</p> <p>I developed and tested the code in a console application first and it worked fine. But when i migrated from console to windows service it started misbehaving. Its giving various exception as:</p> <p>1) Here is the exception that I get when running the service. Service cannot be started. System.Runtime.InteropServices.COMException (0x80020009): Cannot complete the operation. You are not connected. at Microsoft.Office.Interop.Outlook.NameSpaceClass.GetDefaultFolder(OlDefaultFolders FolderType) at ClassLibrary.BaseService.SortInbox() in C:\Users\Neemus\Documents\Visual Studio 2008\Projects\ClassLibrary\ClassLibrary\BaseService.cs:line 48 at ClassLibrary.BaseService.Update() in C:\Users\Neemus\Documents\Visual Studio 2008\Projects\ClassLibrary\ClassLibrary\BaseService.cs:line 311 at ServiceAtBase.UpdateService.OnStart(String[] args) in C:\Users\Neemus\Documents\Visual Studio 2008\Projects\ServiceAtBase\ServiceAtBase\UpdateService.cs:line 24 at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)</p> <p>2)Microsoft Outlook has encountered an error and needs to close.</p> <p>3)outlookObj.AnserWizard threw an exception of type 'System.Runtime.InteropServices.COMException'</p> <p>Here is my code:</p> <p>bool isOutlookRunning = false;<br/>            Process[] process = null;<br/>            process = Process.GetProcessesByName(&quot;OUTLOOK&quot;);<br/>            if (process.Length &gt; 0)<br/>                isOutlookRunning = true;<br/>            try<br/>            {<br/>                obj2 = new Microsoft.Office.Interop.Outlook.Application();<br/>            }<br/>            catch<br/>            {<br/>                if (isOutlookRunning)<br/>                {<br/>                    foreach (Process pr in process)<br/>                    {<br/>                        if (pr.ProcessName.Contains(&quot;OUTLOOK&quot;))<br/>                        {<br/>                            pr.CloseMainWindow();<br/>                         }<br/>                    }<br/>                }<br/>                else<br/>                Process.Start(&quot;OUTLOOK&quot;);<br/>                obj2 = new Microsoft.Office.Interop.Outlook.Application();<br/>            }<br/>            ns = obj2.GetNamespace(&quot;MAPI&quot;);<br/>            inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);<br/>            outboxFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);<br/>            process = null;</p> <p> </p> <p>These errors are not fixed as well.</p> <p>At one time one exception will pop up and other time some other.</p> <p>Any help will appreciated...</p> <p>Thanks</p><hr class="sig">Sunil SachdevaSat, 28 Nov 2009 09:23:20 Z2009-11-28T09:23:22Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/34615d91-0637-4289-b13e-0dd13e0bac1bhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/34615d91-0637-4289-b13e-0dd13e0bac1bSunil Sachdevahttp://social.msdn.microsoft.com/Profile/it-IT/?user=Sunil%20SachdevaHaving doubts over windows serviceHello everyone, Can any one tell me when we go to develop a windows service what role does the service account play? If i give account of the computer administrator what can be the drawbacks??? What is the difference between Local system account and administartor account(in terms of privileges)??? Thanks in advance,<br/>Sat, 28 Nov 2009 06:00:14 Z2009-11-28T08:27:58Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/3c2822ef-e5db-4f87-a127-f66470469584http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/3c2822ef-e5db-4f87-a127-f66470469584ohannahttp://social.msdn.microsoft.com/Profile/it-IT/?user=ohannaCalling System.Diagnostics.Process.Start with the correct parametersI am calling an XP embedded function but my problem has to do with creating the correct string with C#.<br/> <br/> On my command prompt I enter the following:<br/> <br/> C:\Documents and Settings\User 1&gt;   fbwfmgr /commit C: &quot;\\Myfile.txt&quot; &gt;&gt; c:\MyDirectory\output.txt<br/> <br/> Works fine.<br/> <br/> Then I try to do that inside my program as follows:<br/> <br/>       string strCmdLine = &quot;/C fbwfmgr.exe /commit C: \&quot;\\\\Myfile.txt\&quot;  &gt;&gt; c:\\MyDirectory\\output.txt&quot;;<br/> <br/>       System.Diagnostics.Process.Start(&quot;CMD.exe&quot;, strCmdLine);<br/> <br/> And got an error (the error is ERROR_BAD_NETPATH, but it doesn't matter because my problem has to do with not being able to produce the same input in the strCmdLine above to pass to my Process.Start function).  I printed out strCmdLine and it's the same as what I entered on my command prompt except the extra &quot;/C&quot; and &quot;fbwfmgr.exe&quot; instead of the &quot;fbwfmgr&quot; on the command prompt.<br/> <br/> I tried other options of the same command (e.g. string strCmdLine = &quot;/C fbwfmgr.exe /overlaydetails  &gt;&gt; c:\\MyDirectory\\output.txt&quot;;) and they work fine.<br/> <br/> Thanks a lot.<br/> <br/> Info: VS 2005 C#<br/> <br/> <br/>Sat, 28 Nov 2009 05:50:38 Z2009-11-28T06:49:26Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/a539e090-3eac-4cc4-a4a6-dee95630f6c9http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/a539e090-3eac-4cc4-a4a6-dee95630f6c9Abdul-Talhahttp://social.msdn.microsoft.com/Profile/it-IT/?user=Abdul-TalhaLimitation of Schedule TaskHi all,<br/> <br/> I want know limitation of Schedule Task.How many task can i created in windows schedule tasks. Pls reply me<br/> <br/> as soon as possible.<br/> <br/> Thanks and regards <br/> <br/> Abdul Rahiman.<br/>Tue, 24 Nov 2009 14:27:46 Z2009-11-28T06:42:00Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/28d4cb7e-ba40-4e7c-b755-3e879a8a2c39http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/28d4cb7e-ba40-4e7c-b755-3e879a8a2c39Puvaneshttp://social.msdn.microsoft.com/Profile/it-IT/?user=PuvanesCheck Hard disk status (faulty)<p>Hi all, <br/><br/>How to check the hard disk status (working or damaged) in c#? I need to develop an application in c# (vs 2008) which will send alarm when hard disk has any problem or not working.<br/><br/>Thanks.</p><hr class="sig">thanxTue, 24 Nov 2009 07:09:57 Z2009-11-28T06:27:06Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/656c724a-e32e-4f50-802d-04c86baa1f42http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/656c724a-e32e-4f50-802d-04c86baa1f42algateshttp://social.msdn.microsoft.com/Profile/it-IT/?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-28T06:20:08Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/66162d84-ccd0-495b-96bb-c2976382b3b6http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/66162d84-ccd0-495b-96bb-c2976382b3b6Ravish_86http://social.msdn.microsoft.com/Profile/it-IT/?user=Ravish_86How to remove space symbol form Visual studio 2005 text editor<p>H i,</p> <p>In visual studio 2005 text editor, some how some changes has made and due to this changes the text editor display <strong>fullstop('.')</strong> symbol when it recognize any space character. I want to disable this. Can any one  give me suggestion that how to remove fullstop('.') symbol.<br/><br/>Regards<br/>Ravi</p> <p> </p>Fri, 27 Nov 2009 05:32:59 Z2009-11-28T06:13:13Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/b8da0996-0bb1-429d-a16c-1f170408f0d2http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/b8da0996-0bb1-429d-a16c-1f170408f0d2raptor6http://social.msdn.microsoft.com/Profile/it-IT/?user=raptor6Type definition in C# for MS WordHi!<br/>Is there possible to define a type so there ll be no need for writing every time text font, size and style for each row I write to doc?<br/><br/>Thanks1Fri, 27 Nov 2009 20:45:50 Z2009-11-28T05:23:06Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/a3f53739-b134-44fe-8e13-ebde02808c48http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/a3f53739-b134-44fe-8e13-ebde02808c48Joshizzlehttp://social.msdn.microsoft.com/Profile/it-IT/?user=JoshizzleHaving a problem with bitshifting?I can't seem to understand why I get different results using vb.net and c#. I'M using the &lt;&lt; and &gt;&gt; bitshifting functions to shift my byte arrays but i seem to get different results.  <div><br/></div> <div><br/></div> <div><br/></div> <div> <div>VB.NET Code:</div> <div><br/></div> <div><br/></div> <div>Dim Block() as byte = {11, 45, 73, 82, 104, 126}</div> <div>Dim Result(5) as byte</div> <div><br/></div> <div><br/></div> <div><span style="white-space:pre"> </span>Result(0) = Block(0) &lt;&lt; Block(1)</div> <div><span style="white-space:pre"> </span>Result(1) = Block(2) &lt;&lt; Block(3)</div> <div><span style="white-space:pre"> </span>Result(2) = Result(0) &lt;&lt; Block(4)</div> <div><span style="white-space:pre"> </span>Result(3) = Result(2) &gt;&gt; Block(5)</div> <div><span style="white-space:pre"> </span>Result(4) = Block(5) &lt;&lt; Result(0)</div> <div><span style="white-space:pre"> </span>Result(5) = Block(2) &gt;&gt; Result(4)</div> <div><br/></div> <div><br/></div> <div><br/></div> <div>C# Code:</div> <div><br/></div> <div>byte[] Block5 = { 11, 45, 83, 82, 104, 126 };</div> <div>byte[] Result = new byte[6];</div> <div><br/></div> <div><br/></div> <div><span style="white-space:pre"> </span>Result[0] = (byte)(Block[0] &lt;&lt; Block[1]);</div> <div><span style="white-space:pre"> </span>Result[1] = (byte)(Block[2] &lt;&lt; Block[3]);</div> <div><span style="white-space:pre"> </span>Result[2] = (byte)(Result[0] &lt;&lt; Block[4]);</div> <div><span style="white-space:pre"> </span>Result[3] = (byte)(Result[2] &gt;&gt; Block[5]);</div> <div><span style="white-space:pre"> </span>Result[4] = (byte)(Block[5] &lt;&lt; Result[0]);</div> <div><span style="white-space:pre"> </span>Result[5] = (byte)(Block[2] &gt;&gt; Result[4]);</div> <div><br/></div> <div><br/></div> <div><br/></div> <div>Results:</div> <div><br/></div> <div><br/></div> <div><br/></div> <div>VB.NET:</div> <div><br/></div> <div>Result(0) = 96</div> <div>Result(1) = 36</div> <div>Result(2) = 96</div> <div>Result(3) = 1</div> <div>Result(4) = 126</div> <div>Result(5) = 1</div> <div><br/></div> <div>C#:</div> <div><br/></div> <div><br/></div> <div>Result[0] = 0</div> <div>Result[1] = 0</div> <div>Result[2] = 0</div> <div>Result[3] = 0</div> <div>Result[4] = 126</div> <div>Result[5] = 0</div> </div>Sat, 28 Nov 2009 03:56:20 Z2009-11-28T05:02:37Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/8a5ff52e-cbfa-4546-b14f-7ca24755bfadhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/8a5ff52e-cbfa-4546-b14f-7ca24755bfadnemesiscsharphttp://social.msdn.microsoft.com/Profile/it-IT/?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-28T04:50:02Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/e504a078-4efb-48b5-8872-41228469c5bchttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/e504a078-4efb-48b5-8872-41228469c5bcnemesiscsharphttp://social.msdn.microsoft.com/Profile/it-IT/?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-28T04:16:39Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/b0d45d3b-e364-4166-8cf1-2534ef66ccb0http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/b0d45d3b-e364-4166-8cf1-2534ef66ccb0MDMourahttp://social.msdn.microsoft.com/Profile/it-IT/?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-28T02:25:10Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/37b2bedc-1b85-4585-bf05-23bda0de7f12http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/37b2bedc-1b85-4585-bf05-23bda0de7f12LetsGoNativehttp://social.msdn.microsoft.com/Profile/it-IT/?user=LetsGoNativeRegExI need to know the regex pattern to find specific numbers..lets say [0-3] which means I want to make sure the string contains, 0 and 1 and 2 and 3. Any help?Fri, 27 Nov 2009 23:31:36 Z2009-11-28T02:12:44Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/8c44089d-39ae-41b3-84f3-02531324e5fehttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/8c44089d-39ae-41b3-84f3-02531324e5feB. Clay Shannonhttp://social.msdn.microsoft.com/Profile/it-IT/?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-28T00:12:00Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/16a4cf6e-8140-43b2-a21f-744fc196e25ahttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/16a4cf6e-8140-43b2-a21f-744fc196e25anaturefreak827http://social.msdn.microsoft.com/Profile/it-IT/?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-28T00:07:57Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/c8fa99a6-0151-4898-82e8-79665d8cbd76http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/c8fa99a6-0151-4898-82e8-79665d8cbd76Power-Mosfethttp://social.msdn.microsoft.com/Profile/it-IT/?user=Power-MosfetPanel with background Image<p>Hello,</p> <p>i have a Panel with background picture it shows (only the Click half), and the question is how the show the other half only with a click of an button.<br/> <span class="short_text"><span style="background-color:#ffffff" title=tekenen><br/> </span> </span></p> <p><img src="http://img690.imageshack.us/img690/2622/62913458.png" alt=num1></p> <br/>Fri, 27 Nov 2009 21:15:23 Z2009-11-27T23:33:49Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/550475fe-5c57-4b1b-94d1-98324d087111http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/550475fe-5c57-4b1b-94d1-98324d087111raptor6http://social.msdn.microsoft.com/Profile/it-IT/?user=raptor6Troubles with Normal.dotm template while modifying docx <pre>Hi!<br/>I have written following code:<br/>It opens .docx and writes to it fields appropriate data. Writing goes fine,<br/>but every time I close the word (opened manually to check for info) or it is<br/> closed like in this code - I get &quot;Normal.dotm template is used by other user/<br/>application&quot;. And then asking wether I want to save changes I made to it (but I think I didnt made any). <br/>Or I get lastapl.docx is locked for editing by Emperor (me) and<br/>Im promted to choose from 3 options - Open a read only copy; create a local<br/>copy and merge changes later;receive notification when the original copy is <br/>available.<br/> <br/><br/><br/><br/><br/><br/><br/><br/>public static void GenerateCertificate(string Name, string Surname, string Course, string RegNr, string Address, string Phone, string Dir, string Email, string date, string CourseStartDate, string CourseEndDate) { int iTotalFields = 0; Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application(); oWord.Visible = false; //to avoid displaying the Word Application; object strDocName = System.IO.Directory.GetCurrentDirectory() + &quot;//lastapl.docx&quot;; object oTrue = true; object objBool = false; object objNull = System.Reflection.Missing.Value; Document oMyDoc = oWord.Documents.Open(ref strDocName, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull); foreach (Field myMergeField in oMyDoc.Fields) { iTotalFields++; Range rngFieldCode = myMergeField.Code; String fieldText = rngFieldCode.Text; if (fieldText.StartsWith(&quot; MERGEFIELD&quot;) { Int32 endMerge = fieldText.IndexOf(&quot;\\&quot;); Int32 fieldNameLength = fieldText.Length - endMerge; String fieldName = fieldText.Substring(11, endMerge - 11); fieldName = fieldName.Trim(); }<br/> ........................... } //oMyDoc.Save(); //oMyDoc.Close(ref objNull, ref objNull, ref objNull); //false //DocumentSaveAs(oMyDoc, &quot;C://apl.docx&quot;); oWord.Quit(ref objNull, ref objNull, ref objNull); }<br/><br/></pre> Should I use template instead of docx? What will be then Saving procedure?<br/>Thanks!Fri, 27 Nov 2009 23:27:20 Z2009-11-27T23:27:20Zhttp://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/15a7bb3e-34c0-41a0-b7f7-48c851f87696http://social.msdn.microsoft.com/Forums/it-IT/csharpgeneral/thread/15a7bb3e-34c0-41a0-b7f7-48c851f87696raptor6http://social.msdn.microsoft.com/Profile/it-IT/?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-27T22:55:24Z