{"id":3393,"date":"2014-03-23T13:51:26","date_gmt":"2014-03-23T13:51:26","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/23\/windows-forms-forumswindows-forms-generalrelated-issues-collection-of-common-programming-errors\/"},"modified":"2014-03-23T13:51:26","modified_gmt":"2014-03-23T13:51:26","slug":"windows-forms-forumswindows-forms-generalrelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/23\/windows-forms-forumswindows-forms-generalrelated-issues-collection-of-common-programming-errors\/","title":{"rendered":"windows-forms-forums,windows-forms-generalRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nI am creating a delete button for a project I am working on, but when I try to delete the selected value from a database it gives me an error of index out of range. \u00a0And the value return is -1.The code below is what I am working on:private void btnDeleteBook_Click(object sender, EventArgs e)\u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 string sql;\u00a0 \u00a0 \u00a0 \u00a0 if (lstBooks.SelectedIndex == -1)\u00a0 \u00a0 \u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ShowMessage(&#8220;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nRequirement: 1. Open an Excel 2007 file ( .xlxs)2. Find out all the pivot tables in the workbook.3. Set parameters to the pivot tables(i.e. Change the filter values for these Pivot tables)Whats done:1. I created a windows application2. Addded Microsoft Excel 12.0 Object Library and Microsoft Office 12.0 Object Library. 3. Now I try to create a new excel object.4. Map it to the excel file i want .Microsoft.Office.Interop.Excel.Application objExcel;Microsoft.Office.Interop.Excel.Workbook objWrk;Ob<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums clickonce-and-setup-amp-deployment-projects<br \/>\nHi,We have a clickonce deployment for our WPF application but some of our clients can&#8217;t seem to download the application.Comparable caseClient 1: Direct internet connection, desktops have Win XP with\u00a0IE 7, laptops have Vista with\u00a0IE 7. No issues downloading or running the application.Client 2: Direct internet connection, laptop with Win XP with IE 7.\u00a0 Cannot download the application.Client 1 is in the U.S. Client 2 is in Singapore (can&#8217;t see why that should make a difference but I offer the info<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nHii All,My application information:Windows Forms Application.Net Framework 2.0\u00a0Visual Basic 2008I have thenext problem:I was using Windows XP and my application was running successfully, then I installed Windows 7 and when I run my application I got error and the exe file doesn&#8217;t work,when I read the error string I found the problem in generating the application resources, so I went to the error line and it was in the next property in the underlined line:FriendReadOnly Property AC()As Syste<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums clickonce-and-setup-amp-deployment-projects<br \/>\nI am attempting to install an msi on an amazon EC2 machine, my older msi works and I did not change anything with any app configuration, just the content of a few pages. IIS is installed and compatibility is enabled for iis 6. Below is the verbose errorlog. It apears to be msi error 1615 which is earlier in the log, but at the end, i also get errors 1708 and 1709 \u00a0but I am unsure of how to get around this issue. Thanks for your help.\u00a0Here is the end of the log\u00a0=== Logging stopped:<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums clickonce-and-setup-amp-deployment-projects<br \/>\nI am building a deployment package on Windows 2003 and deploying it to another Windows 2003 box.\u00a0 In the log file, the first major error appears to be:&#8221;DEBUG: Error 2769:\u00a0 Custom Action WEBCA_GatherWebSites did not close 2 MSIHANDLEs.The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2769. The arguments are: WEBCA_GatherWebSites, 2, &#8220;The verbose log file is as follows:=== Verbose logging started: 2<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nHi all,I am developing an applicationaccording to user requirment i want fix the form positionfor doing that i write the following code\u00a0private void Form1_Move(object sender, EventArgs e)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 this.Location = new Point(100, 100);\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;nb<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-designer<br \/>\nI moved the Type Abc.Def.Core.BaseControl from Assembly Abc.Def.Core.dll to Abc.Def.Interface.BaseControl in Assembly Abc.Def.Interface.dll. Now inside the same solution there are other projects where I have some UserControls that derive from BaseControl. After the move the designer can&#8217;t load any of them. I get the following errormessage:Could not load type &#8216;Abc.Def.Core.SomeObject&#8217; from assembly &#8216;Abc.Def.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&#8217;. at Abc.Def.Interface.BaseCon<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-sample-applications<br \/>\nHi,\u00a0 I am having some problems in Windows 8 with one of my .NET applications. The problem is that this application launch an old\/legacy application(VB6 application) that connects to an database, reads the patch level of the database and return it to the.NET application via exit\/return code, the .NET application read it and decide what to do in base of\u00a0its value.\u00a0 This proccess was implemented a lot of years ago and it has been working succesfully up to now in all the operating sys<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nI&#8217;m having some difficulty with the Enter and Leave events of a data entry UserControl (UCDE) that a navigation UserControl (UCNav) instantiates using Reflection and then Selects.\u00a0In particular, I&#8217;m perplexed by the firing of UCDE&#8217;s Enter AND Leave events following the Select.UCNav contains a list of the names of other UCs, including UCDE.\u00a0 UCNav is displayed in Panel1 of a SplitContainer and UCDE (and the other UCs when selected) are displayed in Panel2.When I click on the name of UCD<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nI am creating a delete button for a project I am working on, but when I try to delete the selected value from a database it gives me an error of index out of range. \u00a0And the value return is -1.The code below is what I am working on:private void btnDeleteBook_Click(object sender, EventArgs e)\u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 string sql;\u00a0 \u00a0 \u00a0 \u00a0 if (lstBooks.SelectedIndex == -1)\u00a0 \u00a0 \u00a0 \u00a0 {\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ShowMessage(&#8220;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nRequirement: 1. Open an Excel 2007 file ( .xlxs)2. Find out all the pivot tables in the workbook.3. Set parameters to the pivot tables(i.e. Change the filter values for these Pivot tables)Whats done:1. I created a windows application2. Addded Microsoft Excel 12.0 Object Library and Microsoft Office 12.0 Object Library. 3. Now I try to create a new excel object.4. Map it to the excel file i want .Microsoft.Office.Interop.Excel.Application objExcel;Microsoft.Office.Interop.Excel.Workbook objWrk;Ob<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nHii All,My application information:Windows Forms Application.Net Framework 2.0\u00a0Visual Basic 2008I have thenext problem:I was using Windows XP and my application was running successfully, then I installed Windows 7 and when I run my application I got error and the exe file doesn&#8217;t work,when I read the error string I found the problem in generating the application resources, so I went to the error line and it was in the next property in the underlined line:FriendReadOnly Property AC()As Syste<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nHi all,I am developing an applicationaccording to user requirment i want fix the form positionfor doing that i write the following code\u00a0private void Form1_Move(object sender, EventArgs e)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 this.Location = new Point(100, 100);\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&amp;nb<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nI&#8217;m having some difficulty with the Enter and Leave events of a data entry UserControl (UCDE) that a navigation UserControl (UCNav) instantiates using Reflection and then Selects.\u00a0In particular, I&#8217;m perplexed by the firing of UCDE&#8217;s Enter AND Leave events following the Select.UCNav contains a list of the names of other UCs, including UCDE.\u00a0 UCNav is displayed in Panel1 of a SplitContainer and UCDE (and the other UCs when selected) are displayed in Panel2.When I click on the name of UCD<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nDoes anyone know how to fix the DateSelected event for the monthcalendar. I created a custom datetimepicker utilizing the monthcalendar control. When a user is clicking the arrows going from month to month and accidentally clicks the header, the DateSelected event fires.Thanks<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nYesterday I coded a class derived from a Form, with an overriden ToString() method returning the title I wanted it to have in a ListBox.\u00a0 Elements were added to the ListBox, as was visible in the Visual Studio debugger, and by clicking to highlight blank lines of the ListBox.Today, I found that I could make the titles appear if instead oflist.Items.Add(form); I used list.Items.Add(new a(form));Where a is defined as:Code Snippetnamespace ns{\u00a0\u00a0\u00a0 class a\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public object b;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 public a<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nHiWhen I use the RichTextBox.Select(int start, int length) function to select text in a rich text box that contains hyperlinks, there is some shift in the selection when I try to select any text that is after the hyperlink.When I remove the hyperlink, the selection works properly.I use RichTextBox 5 public class RichText50W : RichTextBox{ [DllImport(&#8220;kernel32.dll&#8221;, CharSet = CharSet.Auto)] static extern IntPtr LoadLibrary(string lpFileName); protected override CreateParams Cre<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nI&#8217;m having an issue with an app where my NotifyIcon displays an extra icon. The steps to reproduce it are easy, but the problem is that the extra icon shows up after any of the actual codebehind we&#8217;ve added fires. Put simply, clicking a button triggers executionof method FooBar() which runs all the way through fine but its primary duty is to fire a backgroundworker to log into another of our apps. It only appears if this particular button is clicked.Strangely enough, we have a WndProc method ove<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dn186180.LOGO_Win1211(id-id,MSDN.10).png\" \/><br \/>\nmsdn<br \/>\nwindows-forms-forums windows-forms-general<br \/>\nHi,I have two windows media activeX components on a windows form, accessing the same media file so that I can play it synchronously without the use of a media server. The media file restarts at the end so that it continuously plays. The application works perfectlyand keeps in sync. However, after many hours of running in the IDE enviroment I have seen an occurrence of the the following:&#8221;ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from COM context 0x2063<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>msdn windows-forms-forums windows-forms-general I am creating a delete button for a project I am working on, but when I try to delete the selected value from a database it gives me an error of index out of range. \u00a0And the value return is -1.The code below is what I am working on:private void btnDeleteBook_Click(object sender, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3393","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3393"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3393\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}