Avoid Scrolling for Information

Avoid?Scrolling?in?the?same?document?for?some?information. Using?the windows?”split”?feature?available?in?the?VS.NET IDE?and?you?can?split?the?document?window?into?two?and?have?two?windows?with?the?same?content?aligned?horizontally. You?can?thus?find?the?information?you?were?looking?for?and?avoid?long?scrolls.

Using LINQ Concat to Loop Over Two Arrays with Same Type of Elements

Often, there are multiple collections with the same kind of elements, that we would have to loop on. Instead of writing two for loops over the collections, we can use the Concat operator in LINQ to loop thru the collections in one go. string[] emeaClients = { “John Frank”, “Carine

Add a selectedIndex Changed Event Handler to a ComboBox

When you create the datagridview associate an event handler for its ‘EditingControlShowing’ event. sampleDataGridView.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(DataGridViewEditingControlShowing); And in the event handler add the selectedIndexChanged eventhandler to the combobox. private void DataGridViewEditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { //If second column has the combobox. if (sampleDataGridView.CurrentCell.ColumnIndex == 2) { sampleComboBox = e.Control

Retrieving Data from a Deleted row in a Dataset

You would get the ‘DeletedRowInaccessibleException‘?when you try to access a deleted row in a dataset. To retrieve the information of a deleted row in a dataset, use the overloaded property of DataRow?object. So instead of deletedRow[columnname], use deletedRow[columnname, DataRowVersion.Original].

Can’t use the “Between” Keyword in a LINQ Query

You can’t use the “Between” keyword in a LINQ query. The sample snippet below shows how you translate between two date fields. DateTime fromDate = DateTime.Now.AddMonths(-3); DateTime endDate = DateTime.Now; //linq query var result = from te in datatable.AsEnumerable() where (te.Field(“Month”) = fromDate) && (te.Field(“Month”)

Turn Off the Index Maintenance of DataTable when you Load Data

A Dataset maintains an index, or many indexes, to facilitate the high performance when it is traversed for data. An example of such a situation is when you use the Find or a Select option looking to filter for DataRows on a condition. So, when you are loading rows into

Copy the WebBrowser Control’s Text in HTML Format

To copy the HTML document of the WebBrowser control in HTML format, you need to use the IHTMLDocument2 object of the MSHTML class. For this, you need to add a reference to Microsoft.mshtml assembly which can be found in C:Program FilesMicrosoft.NETPrimary Interop Assemblies folder. Then write the following code in

Retrieving Multiple Record Sets Through a DataReader

If a stored procedure returns multiple record sets, and if you are using the DataReader to retrieve the results, you can use the NextResult method of the DataReader to iterate through the Record Sets. Sample shown below: SqlConnection conn = new SqlConnection(“connectionStringValue”)); conn.Open(); using (conn) { using (SqlCommand command =

Copy the WebBrowser Control’s Text into Windows Clipboard

The WebBrowser control’s document object gives us the ExecCommand method that takes in dom commands such as ‘SelectAll’, and ‘Copy’ which can copy the text for you. You need to add a button (btnCopyHTML in my example) and add the text below to its click event. private void btnCopyHTML_Click(object sender,

No more posts to show