Posts

Donate

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(DateTi

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

Donate