thank you, tried it, but i can't debug solution when i add
CsvReaderViewModel vm = new CsvReaderViewModel("my source");
DataContext = vm;
near InitializeComponent();
thank you, tried it, but i can't debug solution when i add
CsvReaderViewModel vm = new CsvReaderViewModel("my source");
DataContext = vm;
near InitializeComponent();
Hi, i tried this code to parse CSV file and save data in a wpf data grid, the code is correct but i can't store values on datagrid this is a class wich contain the code: public class CsvParser { public List ReadAndParseData(string path, char separator) { var parseData = new List(); using (var sr = new StreamReader(path)) { string line; while ((line = sr.ReadLine()) != null) { string[] row = line.Split(separator); parseData.Add(row); } } return parseData; } } } the is the code behind; assigned to event click on boutton List parseData = csv.ReadAndParseData(datasource, ';'); foreach (string[] row in parseData) { MessageBox.Show(""+row.GetValue(0));// i get the correct value dgvreceipient.Items.Add(row.....);// but i get a empty datagrid }
Hi, i'm developping a wpf application and i use an EDM to generate DATABASE, i have the EDM in a separate class library, and i have added a refernce to my main project and i have added also an app.config in may main project wich contain the connetionstring their. but I am getting the following error when attempting to connect to the EDM: "The specified named connection is either not found in the configuration, not intended to be used with the EntityClient Provider, not valid." can i add the connection string in app.xaml??
I am a student and I'm doing my final year project and this project is the first work with WPF, I downloaded a book and I make every effort to learn because I believe in that "le difficile c'est le chemin" and I asked a lot of questions because I have a month to develop my application also it is not MVVM because company demanded another architecture...thank you
Hi, i have 2 tabitem, each one cotain a wpf gdatagrid i want to pass data from grid1 in tabitem1 to grid2 in tabintem2 when i click on tab item2 or on boutton. i tried this code but i get exception: L'élément possède déjà un parent logique. Il doit être détaché de l'ancien parent avant d'être attaché au nouveau.
private void btnValidate_Click(object sender, RoutedEventArgs e)
{
for (int j = 0; j < i - 1; j++)
{
TextBlock x = dgrecep.Columns[0].GetCellContent(dgrecep.Items[j]) as TextBlock;// GRID1 TABITEM1
if (x != null)
{
if (v.validate(x.Text))
{
dgrecep2.Items.Add(dgrecep.Columns\[0\].GetCellContent(dgrecep.Items\[j\]));//GRID2 TABITEM2
}
else
{
MessageBox.Show("non valide");
}
i tried to bind data from datatable to wpf datagrid with code behind
Binding b = new Binding();
ExcelParser exc = new ExcelParser();
DataTable dt = exc.GetDataTableExcel(datasource);
b.Source = dt.DefaultView;
b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
b.Path = new PropertyPath("F1");
this.dgvreceipient.SetBinding(TextBlock.TextProperty, b);
when i use xamlcode it work:
but i need to have this on code behind.
thnk you, please I tried to use interface: this is the code but it doesn't work
public interface Iimportdata
{
DataView GridData { get; set; }
}
//traitement2--Excel
private DataView Data = null;
public DataView GridData
{
get
{ return Data;
}
set
{
Data = value;
NotifyPropertyChanged("GridData");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
private void btnExcel_Click(object sender, RoutedEventArgs e)
{
ExcelParser exc = new ExcelParser();
DataTable dt = exc.GetDataTableExcel(datasource);
Iimportdata imp = Window.GetWindow(this) as Iimportdata;
imp.GridData = dt.DefaultView;
gbReceipient.Visibility = Visibility.Visible;
btnValidate.Visibility = Visibility.Visible;
}
XAML:
:(
Hi, I try to import data from an Excel file and display it in a datagrid, the data are email addresses. i want that data will be shown on
but when i click on boutton, another DataGridColumn appears with data, but i want that data shown on DataGridColumn="Adress" code of parse:
public class ExcelParser
{
public DataTable GetDataTableExcel(string datasource)
{
OleDbConnection theConnection = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=" + datasource + ";Extended Properties=\\"Excel 8.0;HDR=NO;IMEX=1;\\"");
theConnection.Open();
OleDbDataAdapter theDataAdapter = new OleDbDataAdapter("SELECT \* FROM \[Feuil1$\]", theConnection);
DataTable dt = new DataTable();
theDataAdapter.Fill(dt);
return dt;
}
xaml:
boutton click excel code behined:
private void btnExcel_Click(object sender, RoutedEventArgs e)
{
wpfOpenfiledialog o = new wpfOpenfiledialog();
o.openfich(1);
datasource = o.filename;
ExcelParser exc = new ExcelParser();// class to get data from excel files
DataTable dt = exc.GetDataTableExcel(datasource);
//dgvreceipient.ItemsSource = dt.DefaultView;=========>the problem that this ligne will show another column
}
i try to change the size of text in ritchbox with code behind
TextRange tr = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);
tr.ApplyPropertyValue(FontSizeProperty, (double)9);
but i want to change
tr.ApplyPropertyValue(FontSizeProperty, (double)9)
by
double size=Convert.ToDouble(comboboxfontsize.selectedItem)// or selected value;
tr.ApplyPropertyValue(FontSizeProperty, size)
i get an exception Impossible d'effectuer un cast d'un objet de type 'System.Windows.Controls.ComboBoxItem' en type 'System.IConvertible'. so how can i get the value selected item?
Hi, i have a wpf user control wich allow me to show print window . how can i show wpf user control when i click on button in another window??
I create a library of these classes contains a user control that contains images as background to some button, I add it to the main page such as referance, I added this code to retrieve the control xaml user
but i get an exception: the user control Cannot locate resource :^)
yes i can connect from mangemenet studio and i configured it
Hi, i use Visual C# express 2010 to develop my application. I installed sql server 2008, I tried to generate the database from EDM and when I want to connect to sql server I can't find the provider of Microsoft Sql Server
how can i get cell value from wpf datagrid? this code, wich used to validate data (email adress) from datagrid private void button2_Click(object sender, RoutedEventArgs e) { Validator v =new Validator();// class... String item = dgv1.CurrentCell.Item.ToString(); if (v.validate(item)) { MessageBox.Show("ok"); } else { MessageBox.Show("no"); } }
i Stick a breakpoint on the line combdb.ItemsSource = ConnexionSqlServer.GetDataBasesNames() wich is the method that fill the combobox, i get the exception on combobox although the method returns the names of the database when I test every single button while it works but the problem is when I migrate from one button to another
i Stick a breakpoint on the line combdb.ItemsSource = ConnexionSqlServer.GetDataBasesNames() wich is the method that fill the combobox, i get the exception on combobox although the method returns the names of the database when I test every single button while it works but the problem is when I migrate from one button to another
I stick a breakpoint on the line that's raising the exception, and i get combobox item=null
combdb.SelectedItem=null
the connexionmysql is a static class witch contain the connection with database with the method"getconnexion" and function "getdatabasenames"
yes i created mysql connexion in a class //if (ConnexionMysql.getConnexion(datasource))