Posts

Donate

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