Category Archives: C#.Net

ILT – How to convert string to enum in C#

15-08-2012 How to convert a value to an enum? How to find the matching enum value? Convert object to enum? How to use Enum.Parse method? Solution: Use the Enum.Parse method as shown below to convert your value to the appropriate … Continue reading

Posted in C#.Net | Tagged , , , , | Leave a comment

Unable to cast COM object of type error {6D5140C1-7436-11CE-8034-00AA006009FA}

08-08-2012 I got this error today from SQL Server Management Studio. It occurred when I was trying to brows databases by expanding the “Databases” folder in the SQL Server Management Studio navigation tree. Unable to cast COM object of type … Continue reading

Posted in C#.Net, Computer Security, General Computing | Tagged , , , , | Leave a comment

Is Order Of OleDbCommand.Parameters Important

01-08-2012 The order of the parameters collection of an OleDbCommand must match the order to which those parameters appear in the SQL statement. Otherwise the .net framework will try to fill the parameters in your SQL statement according to the … Continue reading

Posted in C#.Net, Microsoft Access | Tagged , , , , , , , , , , | Leave a comment

How To Change The Combobox Index To Match A Target String

24-07-2012 I need to select “Item1” from the combo box. In other words, I need to select the index that matches the string in the “temp” variable and select that index. Solution Note: The FindString looks for a substring. If … Continue reading

Posted in C#.Net | Tagged , , , | Leave a comment

How to Get the Underlying DataRow of a DataGridViewRow

23-07-2012 How to get the underlying data row of the bound data table linked to a DataGridViewRow in a DataGridView? How to get the underlying DataRow of a DataGridView.Row? How to get the underlying DataRow matching to a Selected Row … Continue reading

Posted in C#.Net | Tagged , | Leave a comment

Use of Nullable ?? Operator in C#

20-07-2012 Use ?? operator to tell the compiler how to assign a null-able variable to a non-null-able variable. Menol ILT

Posted in C#.Net | Tagged , , , | Leave a comment

Using Short-Circuit Condition Evaluation in VB using AndAlso and OrElse

02-07-2012 Normally, a programming language stops evaluating a composite condition when it finds one of following scenarios. (Condition 1) AND (Condition 2) Since the above composite condition to evaluate to true, both condition 1 and condition 2 have to evaluate … Continue reading

Posted in C#.Net, Software Engineering Concepts | Tagged , , | Leave a comment

How To Exit or End a C Sharp (C#) Application

12-06-2012 To exit a c# program simply use following command: Environment.Exit(int Status); Status is the integer you return to tell the environment how your program concludes. If it executed according as expected or if it encountered any errors. The commonly … Continue reading

Posted in C#.Net | Tagged , , , , | Leave a comment

How to Suggest Values or Autocomplete Values When A User Types Into a Combo Box

08-06-2012 .Net has a 5 seconds super easy way to achieve this. Use ComboBox.AutoCompleteSource and ComboBox.AutoCompleteMode properties: (Available from .Net 2.0 onwards) Steps: Load all possible values to ComboBox.Items collection – this is the easiest source available. Select Properties of … Continue reading

Posted in C#.Net | Tagged , , | Leave a comment

List.Find Method in C#.NET

30-05-2012 The List.Find method requires a delegate function which can compare an object of the same type of the list and return if the object matches the target object. You can either declare a delegate separately or use following easy … Continue reading

Posted in C#.Net | Tagged , | Leave a comment