|
The dataset has no changes no matter what I try.
And yes, I have tried:
txtName.DataBindings.Add("Text",ds, "UserList.Name",true,DataSourceUpdateMode.OnPropertyChanged);
Made no difference.
I have also tried using a binding source, with breakpoints in the parse and format methods, and both get called, but the dataset remains unchanged.
While experimening, I found that a different dataset that does get updated if I use a datagridview does not get updated if I use a textbox.
|
|
|
|
|
Not sure if it's already solved for you, maybe check if the fields are readonly??
|
|
|
|
|
No, the fields are not read-only.
Because this problem is/was holding my project up, I have resorted to populating the textboxes one-by-one from the dataset, doing validating on the textboxes one-by-one, and then writing the values back to the dataset.
This does set HasChanges to true, and the changes are saved back to the database.
So I can use the table, but not an elegant way to handle things. Especially as the deal includes the source-code.
Maybe a SharpDevelop bug? Searching this forum and MSDN doesn't show anyone else with the problem, but then I imagine not many people use simple-binding to a dataset - mostly I see it where they use textboxes to change values in a gridview. I can get that to work, but then I'd have to use an invisible gridview, which is not really a better solution!!!
Nigel
|
|
|
|
|
You can try wrapping the datarow's column with a class with getter and setter. Remember the implement INotifyPropertyChange on the setter.
Maybe I'll try that tomorrow.
|
|
|
|
|
|
Well, sorry to tell, the databinding works on dataset, at least on mine. The message box will display the changed value:
private void button1_Click(object sender, EventArgs e)
{
string s = "user id=sa;password=PASSWORD;initial catalog=DATABASENAME;data source=SERVERNAME;timeout=90";
IDbConnection con = new System.Data.SqlClient.SqlConnection(s);
IDbCommand cmd = con.CreateCommand();
dataSet = new DataSet();
IDbDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter();
cmd.CommandText = "Select * from Customers";
adapter.SelectCommand = cmd;
adapter.Fill(dataSet);
if (dataSet.Tables[0].Rows.Count > 0)
{
this.textBox1.DataBindings.Add("Text", dataSet, "Table.CompanyName", false, DataSourceUpdateMode.OnPropertyChanged, string.Empty);
propertyGrid1.SelectedObject = dataSet.Tables[0].Rows[0];
}
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show(dataSet.Tables[0].Rows[0]["CompanyName"].ToString());
}
|
|
|
|
|
Tried exactly the same bindings settings, but will just not work.
|
|
|
|
|
What database are you using? My example was using SQL 2005.
You aren't using WPF are you?
As for 22 columns, that's not a lot. Write a simple code generator, read from a CSV file and generate the class with the get/set.
|
|
|
|
|
I'll look into it.
Besides, that is stiull a workaround.
The point is, simple binding should work. Even the parse routine gets called when I change a value - it just doesn't update the dataset at the end of parse!!
Nigel
|
|
|
|
|
Have you tried dragging the fields onto your form from Server Explorer? That seems to produce bound textboxes that work, then you can look at taking it further from there.
|
|
|
|
|
Using SharpDevelop, don'y have Server Explorer
|
|
|
|
|
Hi,
I have a DataGridView whose DataSource is BindingList of objects:
this.peerList = new BindingList<PeerInfo>();
this.dataGridView1.AutoGenerateColumns = true;
this.bindingSource = new BindingSource();
this.bindingSource.DataSource = this.peerList;
this.dataGridView1.DataSource = this.bindingSource;
I have found guides online of how to set up this filtering, but they only work if the source is a DataTable.
Is there a way to mimic this behavior on a BindingList?
Thanks,
klk
(Also, sorry for not using code tags, as they made the generics disappear).
madness ? this.isSparta = true : this.isSparta = false;
|
|
|
|
|
i developed an application.. and this application is doing some events on every 1 hr... but i want this application to run when the system starts.. hope u got what i mean. so can anybody help to achieve this..
i referred some sites but i got confused.. any good refernce is also appriciated.. with some introduct idea..
Thanks in advance..
cheers..
|
|
|
|
|
|
i checked that .. but where should i enter that code..
|
|
|
|
|
You put it in your application according to your needs.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
in application root i have a xml file.
how can i get that file path.
i am using to get file path @"..\..\file name,xml"
when i run it from vs it is working.
but when i Publish it it through an error.
error shows file not found.
how i will solve my problem
can any one tell me.
thanks
|
|
|
|
|
Ajeet mittal wrote: in application root i have a xml file.
how can i get that file path.
i am using to get file path @"..\..\file name,xml"
That is not the application root. That is two levels above the application root.
Ajeet mittal wrote: when i run it from vs it is working.
That is because the XML file is most likely in your project, not the application root.
Ajeet mittal wrote: how i will solve my problem
Don't hard code file paths (relative or absolute) in your application.
Put file paths in the config file and find out from there.
Also, if the XML files are supposed to be in the application root folder then you might want to tell Visual Studio that so that it can copy the XML files to that location when you run your application.
To do that, right click the XML file in the Solution Explorer. Select "Properties" in the context menu. In the Properties ensure that "Build Action" is set to "Content" and that "Copy to Output Directory" is set to either "Copy if newer" or "Copy Always"
|
|
|
|
|
Thanks
I do it what u told.
but when i deploy my project.i still got error message.
File not found.
can u tell me the solution.
what i have to do.
thanking u
|
|
|
|
|
Display the full file path and then see if the file is there. I'll bet it is a relative path and its wrong.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I have a windows application, where i should find the spelling mistakes from a list of xml files.I used the following code and am able to list the misspelled words. The problem is, I have more than 1000 such xml files. Everytime a spell check is happening in an xml file, one Microsoft Word window is opening. To spell chek 1000 such xml files, 1000 word windows are opened at the sametime. But still, i have closed all those windows using code. Eventhen, every window is opened and then it is getting closed. This is visible to the user. Is there any way to hide the Microsoft Word window to the user? Or can i do spell checking without opening word? Please suggest me.
Thanks in advance.
The code i used is
Word._Document doc= app.Documents.Add(ref template,ref newTemplate,ref documentType,ref visible);
app.Visible=false;
doc.Windows.Application.Visible=false;
doc.Words.First.InsertBefore(strDesc);
Word.ProofreadingErrors we=doc.SpellingErrors;
iErrors=we.Count;
for (int i=1; i<=we.Count;i++)
strErrArray.Add(we.Item(i).Text);
app.Documents.Close(ref SaveChanges,ref OriginalFormat,ref RouteDocument);
Please suggest me a good solution.
|
|
|
|
|
I need to display a list which have a text and a button in each row. Which control will be good for this ?
I did this by creating a custom control that wraps TableLayoutPanel. I have create another control which has Label and a Button. Second control will be added to each row in the TableLayoutPanel. Inner control's events are handled by the control which wraps TableLayoutPanel and this control's events are handled on the form. Is this right approach ? Or is there any similar kind of controls available ?
|
|
|
|
|
If I am understanding your question correctly, a TableLayoutPanel having buttons in one column and textboxes in other alone would work.
|
|
|
|
|
|
How is this related to Windows forms?
|
|
|
|