Posts

Showing posts from 2012

Donate

How To Get Textbox Or RichtextBox Value Using pInvoke In Windows API C#

Assuming you already get the pointer handle of the textbox/richtextbox control from source calling function, the snippet to get the content of the edit control is as follows. public const int GWL_ID = -12; public const int WM_GETTEXT = 0x000D; [DllImport("User32.dll")] public static extern int GetWindowLong(IntPtr hWnd, int index); [DllImport("User32.dll")] public static extern IntPtr SendDlgItemMessage(IntPtr hWnd, int IDDlgItem, int uMsg, int nMaxCount, StringBuilder lpString); [DllImport("User32.dll")] public static extern IntPtr GetParent(IntPtr hWnd); private StringBuilder GetRichEditText(IntPtr hWndRichEdit) { Int32 dwID = GetWindowLong(hWndRichEdit, GWL_ID); IntPtr hWndParent = GetParent(hWndRichEdit); StringBuilder title = new StringBuilder(128); SendDlgItemMessage(hWndParent, dwID, WM_GETTEXT, 128, title); return title; } Greg

WPF Webbrowser Loop Through Html Elements And Submit

A question was raised on vbforums on how to invoke click a button using WPF webbrowser control. This sample loads google.com page and writes a sample text on the textbox and then invoking the click button. HTMLDocument document = (HTMLDocument)wbGetHost.Document; foreach (IHTMLElement myelem in document.getElementsByTagName( "input" )) { if (myelem.id != null ) { if (myelem.id.Equals( "lst-ib" ) && myelem.className.Equals( "lst lst-tbb" ) && !document.documentElement.innerHTML.ToLower().Contains( "wikipedia" )) { HTMLInputElement el = myelem as HTMLInputElement; el. value = "Bill Gates" ; HTMLInputElement searchButton = (HTMLInputElement)document.all.item( "btnK" , 0); searchButton.click(); break ; } } } Greg

The Controller For favicon.ico Does Not Implement IController

In an application using Controller factory, i encountered an error as stated in the title. My MVC does not have a favicon.ico. The solution is to add a parameter constraint that does not allow .ico filenames in your routes. I got the solution from forums.asp.net routes.MapRoute( "Default" , // Route name "{controller}/{action}/{id}" , // URL with parameters new { controller = "ProductView" , action = "Index" , id = "" }, // Parameter defaults new { controller = @"[^\.]*" } // Parameter constraints (regex/string expression) );

How To Count Duplicate Or Repeating Records From Union All Query In SQL

Here's a query to count number of repeating records based from union all query. Union all query does not remove duplicate records. Here's a sample script: select resultsduplicate.url as job_item, count (resultsduplicate.url) as repeat_occurence from ( SELECT url FROM mainTable where id = 47 and url like '%testsite.com%' and _active = 1 UNION ALL SELECT url FROM detailTable where id = 47 and url like '%testsite.com%' and _active = 1 )resultsduplicate group by resultsduplicate.url having ( count (resultsduplicate.url) >1); Original Source From (Stackoverflow.com)

Content Types Or MIME Types List In ASP.NET MVC

I have searched for content types which is suitable for ASP.NET or ASP.NET MVC applications using the HttpResponse class ContentType property. Here's the website with the MIME list: Mime Type List Here's a sample asp.net/mvc snippet. HttpResponseBase response = context.HttpContext.Response; response.ContentType = "application/pdf" ; Greg

WPF Controls Not Rendering Properly Or Correctly On Windows 7 OS

The problem was that the windows 7 theme was changed to classic window . Turning it back to Windows 7 default view, solved it. Greg

Check If Controls On another WPF Window Have Been Rendered Using Multithreading

Given you have two WPF windows namely MainWindow and OtherWindow. You basically want to check if the controls in main window have successfully loaded using statements in OtherWindow. The solution is to use Application dispatcher object. if (Application.Current.Dispatcher.CheckAccess()) { while ( true ) { foreach (Window window in Application.Current.Windows) { if (window.Title.Equals( "Project Title" )) { if (window.FindName( "your_control" ) != null ) { //do your stuff here... } } } break ; } } else { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(CheckMainWindow)); } Cheers!

Garbage Collection GC.Collect() Method In C# Slowing Web Crawlers Speed

In our web crawlers, we encountered slow crawling of items specially XML feeds. We checked our codes if there are lines generating bottlenecks. It turned out that we placed GC.Collect() in an inner loop that's processing item per item. The solution is to comment out GC.Collect() in the inner loop and transfer it to the outer loop statement. Here's the code: while (!EndOfPage) { do { if (date != String.empty) { //comment this statement, transfer outside inner loop... //GC.Collect(); //processing of items code statements... } } while (!(url.Equals(String.Empty))); GC.Collect(); PageNo++; if (PageNo > totalPage) { EndOfPage = true ; } } Credits to my fellow developer for the discovery. Greg

Regular Expression Match Capture Index Property Returns 0 Instead Of -1 In C#

Yesterday, while working on Regex Index property, I encountered a weird problem. Supposedly, string.indexOf(string variable) returns -1 value if there's no occurrence of such substring. However, using Regex.Match(source.ToLower(), @"regex pattern" ).Index returns 0 if instead of -1 if no such substring occurs. The solution was pointed out in stack overflow: Return index position of string after match found using Group.Success in which case returns a boolean value. So, here's the tip: if ((Regex.Matches(source.ToLower(), @"<ol[^>]*>" ).Count < 1) && (Regex.Matches(source.ToLower(), @"<ul[^>]*>" ).Count > 0)) { if (Regex.Match(source.ToLower(), @"<ul[^>]*>" , RegexOptions.IgnoreCase).Success) { // your if statements here.... :) } } Greg

Custom DatagridviewCheckboxColumn In Windows Forms

Image
Hello, Here's a simple class implementation of a DatagridviewCheckboxColumn. public class DatagridviewCustomCheckboxColumn : DataGridViewCheckBoxColumn { public DatagridviewCustomCheckboxColumn() { this .CellTemplate = new DatagridviewCheckboxCustomCell(); } } class DatagridviewCheckboxCustomCell : DataGridViewCheckBoxCell { public int row_index { get ; set ; } public int CheckboxHeight { get { //your_desired_checkbox_height is a variable //that contains the desired height of your checkbox //you may set or get the property value.. return your_desired_checkbox_height; } } public int CheckboxWidth { get { //your_desired_checkbox_width is a variable //that contains the desired width of your checkbox //you may set or get the property value.. return your_d...

How To Highlight GridView Row On Click In ASP.NET Web Forms

This is based from the article of Vincent Maverick Durano's blog on HIGHLIGHT GRIDVIEW ROW ON CLICK AND RETAIN SELECTED ROW ON POST BACK. I just added some statements on javascript to check if the selected row is less than total gridview row count and server side code for paging. JAVASCRIPT CODE: <script type= "text/javascript" > var prevRowIndex; function ChangeRowColor(row, rowIndex) { var parent = document.getElementById(row); var currentRowIndex = parseInt(rowIndex) + 1; //count number of gridview rows var rowscount = $( "#<%=grdCustomer.ClientID %> tr" ).length; if (prevRowIndex == currentRowIndex) { return ; } else if (prevRowIndex != null ) { parent.rows[prevRowIndex].style.backgroundColor = "#FFFFFF" ; } //check if current index is a number... if (IsNumeric(currentRowIndex)) { //check if row index ...

Get Absolute Server Path Of Resources In ASP.NET MVC

In a scenario where you want to load images or other resources, Url.Content() does not return the exact resource path like this (D:\Cart\CartProject\Images\Item4.jpg) . Hence, resulting into a null exception or empty resource. Instead of using Url.Content() or ResolveUrl(), i get the server path of the resource using HttpContext of the application. return new ImageResult(HttpContext.Server.MapPath( "~/Images/Item" + id + ".jpg" )); Note: Testing is done locally and not on a virtual directory... Source: Find Absolute Path the the App Data Folder from Controller Cheers!

Display Bitmap Image In ASP.NET MVC View From Database With Image Data Type

I encountered this weird problem rendering bitmap image from a database table that a friend of mine develops in his company. The task is to display the image on the mvc view. I thought it was a gif or jpeg or png format. But to my surprise as I rendered the binary data on webpage, the image was a bitmap type.. The code to show the bitmap image is as follows. That is to render the bitmap image into a jpeg format. C# Code: public ActionResult ShowCategories () { var model = from n in oContext.ApplianceCategories select n; return View (model); } public void ShowImage ( int id) { var image = ( from m in oContext.ApplianceCategories where m.CategoryID == id select m.Picture).FirstOrDefault(); TypeConverter tc = TypeDescriptor.GetConverter( typeof (Bitmap)); Bitmap bitmap1 = (Bitmap)tc.ConvertFrom(image); bitmap1.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); } I got the trick from stack o...

ASP.NET MVC generates error = "OutputStream is not available when a custom TextWriter is used"

In a simple application I'm creating, I have a custom ActionResult class that returns an image data. In my view, I simply used: <%= Html.Action( "GetImage" , "ImageCustom" , new {id = item.CategoryID}) %> to call the custom action class ExecuteResult method. This method reads the image byte array and store's it in a stream object. However, the call generates an error stated in the title. Html.Action writes html which implements text writer class. The solution would be using Url.Action() embedded in the image src attribute: <img src= '<%= Url.Action("GetImage","ImageCustom", new {id = item.CategoryID}) %>' alt= "No Photo" width= "100" height= "100" /> Greg

Object doesn't support property or method call in consuming JSON object From ASP.NET MVC In Internet Explorer

Recently, I've followed a simple tutorial regarding consuming JSON object in ASP.NET MVC. The error stated from the title of this post appears in IE9. The original snippet is this: $(document).ready( $.getJSON( 'http://localhost:6222/home/customerjson' , function (item) { $( '#result' ) //show product name in .html( '<p>' + item.CurrentCustomer.CustomerName + '</p>' ); } ) ); The solution is to enclose $.getJSON() in a function() statement based from the modified code below. The popup script just went away. $(document).ready( function (){ $.getJSON( 'http://localhost:6222/home/customerjson' , function (item) { $( '#result' ) //show product name in .html( '<p>' + item.CurrentCustomer.CustomerName + '</p>' ); } ) ...

Eliminate Duplicate Rows In A DataTable In C#

Assuming you have a datatable that has merged contents from different datatables and you want to eliminate the datatable with distinct rows, you can use the statement below. dt.DefaultView.ToTable( true , new string [] { "id" , "name" }); Cheers!

Column 'column_name' Already Belongs To Another DataTable in C#

In a scenario where I added columns using AddRange(), I encountered an error as specified by the title. Here's the C# code: table1.Columns.AddRange( new DataColumn[] { col1, col2, col3 }); table2.Columns.AddRange( new DataColumn[] { col1, col2, col3 }); Where col1, col2, col3 are DataColumn objects. What I did was to initialize columns in the addrange method. But there are other solutions in the forums. table1.Columns.AddRange( new DataColumn[] { new DataColumn( "ID" ), new DataColumn( "WEB ID" ), new DataColumn( "URL" ) }); table2.Columns.AddRange( new DataColumn[] { new DataColumn( "ID" ), new DataColumn( "WEB ID" ), new DataColumn( "URL" ) });

WPF Datagrid (Prevent DataGrid Last Row From Being Sorted On Column Header Clicked)

Image
Here's the WPF version of prevent total rows from being sorted. Images: 1. Form Load, no column header is clicked (unsorted records) 2. Name header is clicked (sorting by column). The names are sorted alphabetically. Below are the methods used: /// <summary> /// column header clicked(sorting) /// </summary> private void dgProducts_Sorting( object sender, DataGridSortingEventArgs e) { DataRowView rv = (DataRowView)dgProducts.Items[dgProducts.Items.Count - 1]; if (rv[0].ToString().Contains( "Total:" )) { dvCopy = dgProducts.Items.SourceCollection as DataView; rv.Delete(); } sorted_aborted = e.Handled; } /// <summary> /// layout is updated /// </summary> private void dgProducts_LayoutUpdated( object sender, EventArgs e) { if (!sorted_aborted) { ...

Add Checkbox In WPF Datagrid DatagridTemplateColumnHeader (For Checkall)

Image
Hello, Here's how to add checkbox in WPF Datagrid DatagridTemplateColumn to simulate checkall. I have included the TSQL script, XAML and C# codes. Perform these steps below 1. Create an MSSQL database with the following Product Table schema below: Table: Products Fields: -    ProductID (int, autoincrement) -    ProductName (varchar) -    UnitPrice (decimal) -    QuantityPerUnit (varchar) -    Discontinue (bit)  SQL Script: USE [Your_Database_Name] GO /****** Object: Table [dbo].[Products] Script Date: 05/27/2013 14:07:39 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Products]( [ProductID] [int] NOT NULL , [ProductName] [varchar](50) NULL , [UnitPrice] [decimal](18, 2) NULL , [QuantityPerUnit] [varchar](50) NULL , [Discontinue] [bit] NULL , CONSTRAINT [PK_Products] PRIMARY KEY ...

Prevent DataGridView Last Row From Being Sorted On Column Click

Image
Hello, You might have a row in the DataGridView typically the last one that computes total and the grid control is unbound to a datasource. And then if a sorting event occurs, you dont' wanna include that row during sort event. So given that your application has a form and a DataGridView control, the code to perform databinding is handled in the Form Load Event. DataGridViewRow dgRowTotalCount; DataTable dataTable; private void Form1_Load ( object sender, EventArgs e) { DataTable dt = new DataTable( "tblEntTable" ); dt.Columns.Add( "ID" , typeof ( string )); dt.Columns.Add( "Amount" , typeof ( decimal )); dt.Rows.Add( new object [] { "1" , 100.51 }); dt.Rows.Add( new object [] { "2" , 200.52 }); dt.Rows.Add( new object [] { "6" , 500.24 }); dt.Rows.Add( new object [] { "8" , 1000.11 }); dt.Rows.Add( new object [] { "4" , 400.31 }); dt.Rows.Add( new object [] { "5" , 6...

Regular Expression Word Boundary Not Working If Using A Variable In C#

In this scenario, I have to match an exact state abbreviation (QLD) that is Queensland. I declared an array containing state constant values. Normally this would work without using a string variable in C#: Regex.IsMatch(address, @"\bQLD\b" ) However, this won't work: if (Regex.IsMatch(address, @"\b" + str + "\b" )) The solution is to put an @ sign on both "\b" of the expression: string [] states = new string []{ "ACT" , "NSW" , "QLD" }; foreach ( string str in states) { if (Regex.IsMatch(address, @"\b" + str + @"\b" )) { state= str; address = address.Replace(str, "" ).Trim(); break ; } }

ASP.NET MVP Design Pattern (Simple)

Image
Out of boredom, I decided to read some ASP.NET Articles and came stumbling to Dino Esposito's MVP Flavors . After reading it, I decided to translate this into an ASP.NET application. I revised specifically the Presenter class since this has most of the interaction. Below are some snippets and screen shots: Image: 1. Solution Explorer for the Sample ASP.NET MVP Site 2. On Drop Down Selection of Customer 3. Button Expand Is Clicked, Show other records on other textbox controls. Presenter Class: public class Presenter { private IDefaultView view; public Presenter(IDefaultView viewObject) { view = viewObject; } public void InitializeView() { : view.AddCustomer( "Alfreds Futterkiste" , "ALFKI" ); view.AddCustomer( "Ana Trujillo Emparedados y helados" , "ANATR" ); view.AddCustomer( "Antonio Moreno Taquería" , "ANTON...

Convert Time From A Specific Timezone To Another Using CONVERT_TZ() In MySQL

In this scenario, we have to convert a timezone from Central USA to Hongkong time. I took note of DST here from (-06:00) to (-05:00). Here's a sample query. SELECT CONVERT_TZ( '2012-09-12 04:35:00' , '-05:00' , '+08:00' ) as convert_to_ph; Cheers!

Adding An Item to WPF Datagrid (C#)

Hello! VB.NET Version: Adding An Item to WPF Datagrid (VB.NET) Here's the C# version of how to add an item manually to a WPF DataGrid. DataGridTextColumn c1 = new DataGridTextColumn(); c1.Header = "Test" ; c1.Binding = new Binding( "test" ); c1.Width = 473; dataGrid.Columns.Add(c1); dataGrid.Items.Add( new Names() {test= "just testing" }); Class property: public string test { get ; set ; } XAML code: <DataGrid AutoGenerateColumns= "False" Height= "289" HorizontalAlignment= "Left" Margin= "10,10,0,0" Name= "dataGrid" VerticalAlignment= "Top" Width= "481" Grid.ColumnSpan= "2" ItemsSource= "{Binding }" > </DataGrid>

Add An Item To WPF Datagrid (VB.NET)

Hello! C# Version: Adding An Item to WPF Datagrid (C#) There was a question on visual basic forum on how to add an item to a wpf datagrid. Here's a simple example below. Code view: Dim linkColumn As New DataGridTextColumn : Dim titleColumn As New DataGridTextColumn linkColumn.Header = "Links:" : titleColumn.Header = "Titles:" linkColumn.Width = dataGrid.Width / 2 : titleColumn.Width = dataGrid.Width / 2 linkColumn.Binding = New System.Windows.Data.Binding( "Link" ) : titleColumn.Binding = New System.Windows.Data.Binding( "Title" ) dataGrid.Columns.Add(linkColumn) : dataGrid.Columns.Add(titleColumn) dataGrid.Items.Add( New DataItems() With {.Link = "http://testingme.com" , .Title = "mytesting" }) XAML: <DataGrid AutoGenerateColumns= "False" Height= "289" HorizontalAlignment= "Left" Margin= "10,10,0,0" Name= "dataGrid" Ve...

CREATE DATABASE Permission Denied In Database ‘master’.

I successfully installed MSSQL Server 2008 in my working pc. But when I tried creating a database I encountered an error CREATE DATABASE permission denied in database ‘master’.  I recalled my username has no privilege as domain administrator. So, the solution was to  1. login on my  working pc as domain administrator 2. change server authentication to mixed mode 3. change password of sa. 4. reconnect using sa account That's it...

WPF TimePicker Control

Image
Based from these sources:  a. (http://jobijoy.blogspot.com.au/2007/10/time-picker-user-control.html)  b. Dipitimaya Patra's datepicker in Datagrid I came up with a modified custom timepicker control embedded in WPF Datagrid with databinding features. I encountered bugs on migrating the present time picker custom control throughout development in .Visual Studio 2010 and I manage to fix them myself. The errors are specifically found on the keydown events and time updates (increment/decrement of values). Here are the things that I did to make this work: 1. I added a dependency property to the user control public DateTime TimeValue { get { return (DateTime)GetValue(TimeProperty); } set { SetValue(TimeProperty, value ); } } public static readonly DependencyProperty TimeProperty = DependencyProperty.Register( "TimeValue" , typeof (DateTime), typeof (TimeControlBinding), new UIPropertyMetadata(D...

How To Apply Fore Color Or Font Weight To DataGridView Cell

Here's the code to apply font weight and font color to your datagridview cell. DataGridViewCellStyle style = new DataGridViewCellStyle(); style.ForeColor = Color.Red; style.Font = new Font( this .Font, FontStyle.Bold); dg.Rows[dg.Rows.Count - 1].Cells[i + 2].Style = style;

Check If Mouse Coordinate Is Outside The Form Coordinates In Mouseup Event In C#

This snippet will check if mouse coordinate is outside the form coordinates in mouseup event using the object's ClientRectangle property. private void dgvScriptsTime_MouseUp( object sender, MouseEventArgs e) { if (! this .ClientRectangle.Contains(e.Location)) { FShowGrid showGrid = new FShowGrid( "Test" , dgvScriptsTime); showGrid.ShowDialog(); } }

Show Sql Server Instance On The Network In ASP.NET Web Forms

The key is the SqlDataSourceEnumerator to display all instances. You can use gridview or ajax controls for display purposes. protected void Page_Load( object sender, EventArgs e) { // Retrieve the enumerator instance and then the data. SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance; System.DataDataTable table = instance.GetDataSources(); // Display the contents of the table. DisplayData(table); } private void DisplayData(System.DataDataTable table) { foreach (System.DataDataRow row in table.Rows) { foreach (System.DataDataColumn col in table.Columns) { Response.Write(String.Format( "{0} = {1}<br>" , col.ColumnName, row[col])); } } }

Save RGB Color To SolidBrush Object In C#

To save a RGB color to a Solidbrush object, pass the RGB color in the solidbrush constructor. SolidBrush brush = new SolidBrush(Color.FromArgb(211, 222, 229)); Then apply it in your graphics method. evs.Graphics.FillRectangle(brush, evs.CellBounds); Cheers!

Graphic Lines In Picture Box Gone After Switching Tab Pages In C#

In a program i'm working with, I have a timer event which draws lines or graphs on a picture box. This picture box is inside a tab and panel. When I switched views to other tabs and return to the tab that has the picture box, the previous lines or graphs disappears. I suspect, the controls are redrawn when switching tabs. I tried several solutions and options in picture box paint event and infact tried overriding it. Same results. Luckily, I found a tip in an article to draw the real time graphics on the image itself. This helped solve the issue. Greg

Limit Flickering On Winforms In C#

Here's the snippet to limit flicker in forms. Put it above the initialize component method in your constructor. //limit flicker SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true ); InitializeComponent(); Cheers! Source: mijalko

Process Memory Usage Percentage Not Computing Properly In C#

In a scenario when i want to compute the percentage of a process memory consumption against the total memory installed, I encountered a logic error where in the result is zero. The simple formula is this: double x = p.PrivateMemorySize64 / installed_memory_pc * 100; However, the result in x is zero. The trick is to convert p.PrivateMemorySize64 and installed_memory_pc to megabytes by dividing each variable with 1048576. 1Mb = 1048576 bytes. The modified formula is: mbInstalledMemory = ( int )installedMemory / 1048576; mbUsage = ( int )p.PrivateMemorySize64 / 1048576; Then you can apply the percentage formula. Cheers!

Enable/Disable ToolstripButton Using Delegates (Thread) In C#

Assuming you will access the toolstrip button from another thread, then here's the code on how to enable or disable ToolstripButton using delegates. delegate void EnableDisableButtonRunDeleg( bool value ); private void EnableDisableButtonRun( bool value ) { if (tsMenu.InvokeRequired) { this .tsMenu.Invoke( new EnableDisableButtonRunDeleg (EnableDisableButtonRun), value ); } else { ToolStripItem ts = tsMenu.Items[0]; ((ToolStripButton)ts).Enabled = value ; } } Cheers!

How To Get Icon From Process In C#

If you want to convert to image, just cast it to a bitmap object. Icon ico = Icon.ExtractAssociatedIcon(process.MainModule.FileName); Source: Stack overflow

Prevent Listview Column From Being Resized In Windows Forms C#

I added the snippet below in the columnwidthchanging event: switch (e.ColumnIndex) { case 0: e.NewWidth = 400; break ; case 1: e.NewWidth = 200; break ; case 2: e.NewWidth = 100; break ; case 3: e.NewWidth = 100; break ; default : break ; } e.Cancel = true ; Where 400, 200, and 100 are the original column sizes.

How To Terminate Process That Encounters An Error In C#.NET

Simply set the error data received and terminate the process. private void button2_Click( object sender, EventArgs e) { foreach (Process p in Process.GetProcesses()) { p.ErrorDataReceived += new DataReceivedEventHandler (p_ErrorDataReceived); } } void p_ErrorDataReceived( object sender, DataReceivedEventArgs e) { Process p = (Process)sender; p.Kill(); }

WebBrowser Control In Windows Forms Has Different Document Text Value On Different Computers

We encountered a problem where in a web crawler doesn't run on a remote server, but run perfectly on a local machine. The crawler utilizes the web browser control from microsoft. The problem turns out that the local machine's IE browser is version 9 and the remote server has IE 8. The solution was to re deploy the exe file to another remote server that has IE 9. Cheers!

How To Align Text A Merged Cell In Excel Using C#

The code below shows how to align a text in a merged cell in excel using C#. chartRange.Merge(Type.Missing); chartRange.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; Source: sanket's blog

Object does not contain a definition for get_Range (MS Excel) In C#

Team, Given that you encounter an error such as Object does not contain a definition for get_Range given the original snippet that shows the error below. chartRange = sheet.get_Range(sheet.Cells[row_indicator, column_indicator], sheet.Cells[row_indicator, column_indicator + 11]); The fix to the code snippet above is to cast the cells with object. chartRange = sheet.get_Range(( object )sheet.Cells[row_indicator, column_indicator], ( object )sheet.Cells[row_indicator, column_indicator + 11]); Cheers!

Error 3417 Unable To Start Service In SQL Server 2008

Yesterday, My sql server 2008i stopped working due to error 3417. I tried different solutions as provided by msdn forums and other sites such as compression attributes, network service to be added on security and change log-on to local system and restoring my master db using cmd. All did'nt work. I ended up backing up all my databases, uninstalling the database service but retaining the other features such as business intelligence studio, IDE tools and etc. Then, re installing the database services w/ same credentials as before. Greg

Sort Observable Collection Object In WPF

The snippet below sorts the Observable Collection object which is scriptInfo using time_start which is a property of a strongly typed class. scriptInfo.OrderBy(i => i.time_start); Cheers!

WPF Scroll Viewer Slow Performance (Bind Control Height From Another Object Using Code)

In this post, I created a datagrid dynamically or from code. When a record is loaded, the scrolling is slow using Scrollviewer control. So to translate into code behind here's what i come up. Binding bindHeight = new Binding(); bindHeight.ElementName = String.Format( "sizingElement{0}" , index + 1); bindHeight.FallbackValue = 1; bindHeight.Path = new PropertyPath( "ActualHeight" ); //mapGrid is the datagrid object mapGrid.SetBinding(DataGrid.HeightProperty, bindHeight); XAML Markup: <StackPanel x:Name= "spThur" Height= "Auto" Background= "Green" HorizontalAlignment= "Left" Orientation= "Horizontal" > <Rectangle Name= "sizingElement4" Fill= "Transparent" Margin= "1" Height= "333" /> </StackPanel> The mapGrid datagrid is added to the stackpanel. And the Rectangle object is the sizing element.I found the solution from this ...

Donate