Do you want to display the value that you see in the Company_Name column of the first row in the grid in the TextBox called txtCompany?
You could set the Text property of the TextBox in the LoadCompany method like this:
public void LoadCompany(object sender, RoutedEventArgs e)
{
DbEstimatorDataContext conn = new DbEstimatorDataContext();
List<Company_Control> Company_Controls = (from s in conn.Company_Controls
select s).ToList();
RadCompany.ItemsSource = Company_Controls;
txtCompany.Text = Company_Controls[0].Company_Name;
}
If you want to bind it, you should expose the ItemsSource collection through a property of the DataContext of the TextBlock and specify a valid path to the property you want to bind to:
public partial class wCompany : Window
{
public wCompany()
{
InitializeComponent();
this.DataContext = this:
}
public void LoadCompany(object sender, RoutedEventArgs e)
{
DbEstimatorDataContext conn = new DbEstimatorDataContext();
List<Company_Control> Company_Controls = (from s in conn.Company_Controls
select s).ToList();
RadCompany.ItemsSource = Company_Controls;
var firstRecord = (Company_Controls);
myGlobals.myCompany_Name = Convert.ToString(firstRecord)
myGlobals.myCompany_Name = RadCompany.ToString.("Company_Name");
this.Company_Controls = Company_Controls;
}
public List<Company_Control> Company_Controls
{
get;set;
}
}
<TextBox x:Name="txtCompany" HorizontalAlignment="Left" Height="23" Margin="77,25,0,0" TextWrapping="Wrap"
Text="{Binding Company_Controls[0].Company_Name}" VerticalAlignment="Top" Width="290"
/>
No comments:
Post a Comment