Tuesday, June 22, 2010

Created Issue: Hiding and Showing a column with a TextBlock as the header causes exception [13589]

Created Issue: Hiding and Showing a column with a TextBlock as the header causes exception [13589]: "If you set a column header to a text block (rather than a string), and you set the visiblity of the column to collapsed, then later set the visibility back to Visible grid gives an invalid operation exception "Specified element is already the logical child of another element. Disconnect it first." Below is complete code for a program to demonstrate. Run the program, click the three buttons in order.

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>

</Grid.RowDefinitions>
<DataGrid AutoGenerateColumns="True" Name="dataGrid1" ItemsSource="{Binding}"/>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Button Click="SetTextBlocks_Click">Set Headers to TextBlocks</Button>
<Button Click="Hide_Click">Hide Weight Column</Button>
<Button Click="Show_Click">Show Weight Column</Button>
</StackPanel>
</Grid>
</Window>

Code Behind:

using System.Windows;
using System.Windows.Controls;
using System.Collections.ObjectModel;

namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{

InitializeComponent();

ObservableCollection<Item> Items = new ObservableCollection<Item>();
Items.Add(new Item(1, "John", 200));
Items.Add(new Item(2, "Mary", 100));
Items.Add(new Item(3, "Jane", 150));
DataContext = Items;


}

public class Item
{
public int ID { get; private set; }
public string Name { get; private set; }
public double Weight { get; private set; }

public Item(int id, string name, double weight)
{
ID = id;
Name = name;
Weight = weight;
}
}

private void Hide_Click(object sender, RoutedEventArgs e)
{
dataGrid1.Columns[2].Visibility = System.Windows.Visibility.Collapsed;
}

private void Show_Click(object sender, RoutedEventArgs e)
{
dataGrid1.Columns[2].Visibility = System.Windows.Visibility.Visible;
}

private void SetTextBlocks_Click(object sender, RoutedEventArgs e)
{
TextBlock temp = new TextBlock();
temp.Text = "ID X";
dataGrid1.Columns[0].Header = temp;

temp = new TextBlock();
temp.Text = "Name X";
dataGrid1.Columns[1].Header = temp;

temp = new TextBlock();
temp.Text = "Weight X";
dataGrid1.Columns[2].Header = temp;
}
}
}
"

Sunday, March 14, 2010

Apple OS Learning to Chew Gum and Walk at the Same Time, Multitask Support Coming - HotHardware

Apple OS Learning to Chew Gum and Walk at the Same Time, Multitask Support Coming - HotHardware

Posted using ShareThis

Monday, March 8, 2010

Goole Map WPF windows application


Dear all

a very helpful windows based google map application , this can be used just like web based google map but no need of a browser and an added extra IP search location which is not available in google map.


Click to download the application

Wednesday, March 3, 2010

Sms to India using Way2Sms PHP code


Click to download windows exe



$post_data = "username=username&password=pwd";
//$header_array[]="User-Agent:
$url = "http://wwwa.way2sms.com/auth.cl";
$cookie = tempnam ("/tmp", "CURLCOOKIE");
$ch = curl_init();
curl_setopt( $ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5" );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_ENCODING, "" );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); # required for https urls
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
curl_setopt($ch,CURLOPT_REFERER,"http://wwwg.way2sms.com//entry.jsp");
$content = curl_exec( $ch );
$response = curl_getinfo( $ch );
//$ch = curl_init($url);
//echo $content;
$post_data = "custid=undefined&HiddenAction=instantsms&Action=custfrom450000&login=&pass=&MobNo=9986966496&textArea=test sms";
$url = "http://wwwa.way2sms.com/FirstServletsms?custid=";
curl_setopt( $ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5" );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_ENCODING, "" );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); # required for https urls
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 0 );
$content = curl_exec( $ch );
$url = "http://wwwa.way2sms.com/jsp/logout.jsp";
curl_setopt( $ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5" );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_ENCODING, "" );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); # required for https urls
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 0 );
$content = curl_exec( $ch );

?>