Posts

Showing posts from 2015

Scroll bar disappears on minimizing of window - C# .NET winform

Introduction While working on windows based project, I found a strange issue - on minimizing of window to  task bar  and returning to its normal state by maximizing, some of its controls and scroll bar were disappearing. Those get displayed automatically on changing of window’s state or  re-sizing  of the form. I tried lots to find out its solution over internet but I did not found any good solution, what I found is that this is a .NET bug which has been fixed in framework 4.5, whereas I was using .NET framework 3.5, and therefore looking for alternate solution. For detail, you can visit: http://www.codeproject.com/Questions/124373/scrollbar-disappears-while-resizing-the-window Solution While discussing with my senior, I found a hint about to override base class method OnSizeChanged(). After fighting with code lines while RnD and using Visual Studio class editor help, I found the solution what exactly I was looking, and the solution is given below: protected override

Format string with String.Format() method in C#

While programming you may need to build human understandable line(s) or para with dynamic values. In such cases, mostly developers either choose string concatenation or StringBuilder option in C# language. Manipulating strings with these results in mutability and immutability. For detail, please read difference between string concatenation and StringBuilder. Is it ok for frequent use, or in case of looping, or for large strings manipulations? Consider second case of formatting string with some calculated dynamic values, e.g. Decimal values to currency format, Splitting of date and time from DateTime value, Multiple string manipulation etc. These may become tricky or lengthy, if you choose general programming concepts. Also, to display user friendly messages, always in demand. With this article, we will understand how effectively we can format dynamic value with certain constant string line(s) or in paragraph, with less number of code lines. C# provided String.For

Nuget error: The underlying connection was closed

ERROR: Visual Studio 2010 nuget error: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. Solution: Go to VS2010 -> Tools -> Library Package Manager -> Package Manager Settings Choose Package Manager -> Package Sources. 1. Add a new package source as: Name= NugetSource Source= http://packages.nuget.org/v1/FeedService.svc/ 2. Move Up the newly added package source to first position. 3. UnCheck existing "Nuget official package source" 4. Restart VS2010.

Read HTML table using JavaScript or jQuery

Read complete HTML table- rows & columns values using JavaScript/jQury. To understand this article, you should know about basics of HTML & JavaScript. Read HTML table by its id attribute: var table = document.getElementById('table_id'); Read rows count in the HTML table: var row_count = table.rows.length; Read columns count in the HTML table: var col_count =  table.rows[i].cells.length; You can iterate to read all column values including headers: for (var i = 0; i < table.rows.length; i++)  { var colmns= table.rows[i].cells; for (var j = 0; j < colmns.length; j++)  { if (i == 0) // Read column-header values: table.rows[i].cells[j].children[0].innerText; else // Read column-rows values: table.rows[i].cells[j].innerText; } } .innerHtml - returns HTML element within the specified cell. .innerText - returns text value within the specified cell.

Eliminate dead codes to avoid extra code maintenance

Image
Dead/unreachable codes and member variables: While working with large projects, silly mistakes are common and those may cause memory or performance issues. Developers used to write method and later some methods either they change or comment. This generally happens in case of frequent requirement change. If you have commented the method and function call then there is –“no comment”. But in case you have commented method call and you haven’t commented method definition, or method defined but never used, or variables declared but never used, what about the memory occupied by instance of such class? These codes called as dead codes or in general unreachable codes. Generally, Visual Studio does provide blue under line for unused variables but they have no such facility to unused methods. The problem with these are- more about that you have to care and maintain extra code that is not in use. Also typically when you are about to delete an unused code elements, this might provoke ask