|
Hi All,
I have bound textboxes and other controls on a panel. If I edit the text in a textbox and move on to another control, everything works fine and I can use
HasVersion(DataRowVersion.Proposed)
to determine if there have been any changes to any control.
BUT, if I make only a single change to one text control and leave the panel afterwards by clicking into another panel on the screen, the proposed version flag is not set and I'm missing to save the change to the underlying dataset and database.
Binding:
txtCode.DataBindings.Add("Text", m_vProject, "code");
...
and after leaving the panel:
BindingManagerBase bm = BindingContext[m_vProject];
cPrjDs.tProjectRow prjRow = (cPrjDs.tProjectRow)(((DataRowView)bm.Current).Row);
if (prjRow.HasVersion(DataRowVersion.Proposed)) {
if (MessageBox.Show("save changes?", "header", ...)) {
bm.EndCurrentEdit();
To my understanding, it would be possible to catch the TextChanged event of the control and start DataRow.BeginEdit(), but this does not seem to be a practical solution for lots of controls.
Thanks for any help.
Peter
|
|
|
|
|
when i make a new windows application project and put in the main webform any control like a Button, the application throws overflow exception, but if i tried to run the application without making anychanges the application will run without exceptions, i think the problem isn't in the control because after i got the exception i removed the control from the webfrom but i still have the same error, i don't know why i got this exception while am setting the Checking Overflow/Underflow to false in the project Build properties,
anyone have suggestions ?
thanx in advance .
|
|
|
|
|
SomeOne_SurVive wrote:
when i make a new windows application project and put in the main webform
is it webform, or a windows form?
there are no facts, only interpretations
|
|
|
|
|
sorry, its a windows form , not a webform
|
|
|
|
|
Hi, just want to know what you guys do when you wish to populate DataGrid with DataSet consisting ALL customer records BUT not wanting to load ALL customers records into DataSet (or in other words, memory). For example,
DataSet dsCustomers = new DataSet();
//That's not good, you're potentially loading enough records into memory to bring down your application server.
SqlDataAdapter daCustomers = new SqlDataAdapter(
"select * from Customers", conn);
daCustomers.Fill(dsCustomers, "Customers");
dgCustomers.DataSource = dsCustomers;
dgCustomers.DataMember = "Customers";
Thanks!
Norman Fung
|
|
|
|
|
AFAIK the DataGrid has no way of dynamically loading data. There might be another grid implementation that does support...
Anyway, loading all your customers into a grid isn't a good UI practice. Its impossible to navigate that much information and make use of it. I recommend that you rethink your design to minimize the data to exactly what the user wants to see. Just a suggestion.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Yes, I can ask user to specify a WHERE clause, but solution would be nicer if I dont have to. I think you're right though - the whole point of DataSet is grab all data from SQLAdapter and work disconnected from data source - propagating changes only back to source only when you're all done in the end.
DataGrid.DataSource is anything that implements IEnumerable - Classes that implements this interface includes DataView, ArrayList, and Hashtable. IEnumerable includes one interface method:
IEnumerator GetEnumerator();
Which returns IEnumerator interface - which includes three interface methods:
1. object Current {get;}
2. bool MoveNext();
3. void Reset();
I think one can implement their own IList class, which resembles this:
class CustomerList : IList {
protected int _count=0;
protected Customer _current=null;
protected SQLConnection _con=null;
protected String _sql=null;
public CustomerList(String sql, ref SQLConnection con) {
_sql=sql;
_con=con;
}
property Object Current {
get {return _current;}
}
property int Count {
get {return _count;}
}
bool MoveNext() {
...grab directly from database everytime...
Customer cs=null;
int currentUIN=_current.getUIN() +1;
String filter=" WHERE UIN=" +currentUIN;
String sql=_sql +filter;
SqlCommand cmd= new SqlCommand(sql, _con);
_con.Open();
SqlDataReader rdr= cmd.ExecuteReader();
if(rdr.Read()) {
cs=new Customer();
cs.UIN=currentUIN;
cs.login=res.GetSqlString();
cs.email=res.GetSqlString();
... the rest of it...
_current=cs;
_con.Close();
//Get total count: "SELECT COUNT(*) FROM Customers"
... implementation ...
return true;
} else {
return false;
}
}
void Reset () {...}
}
Then, consuming it:
SQLConnection con=...;
String sql="SELECT * FROM CUSTOMERS;"
MyArrayList customerList= new MyArrayList(sql, con);
dgCustomers.DataSource = customerList;
Of course, you don't get the convenience of SQLDataAdapter.Update(), which propagate changes back in a batch --- ... is it possible to blend DataSet (100% disconnected) and CustomerList (100% connected, grab data as you go) and have the better of the two...
Norman Fung
|
|
|
|
|
I urgently need to create street-level mapping for an area in which there is no available street-level mapping from anywhere. Can somebody indicate as to how I can go about creating such a mapping (e.g. using a paper map to pass coordinates on a c# program to draw the map? can i use a database to store the points?) I am a relatively new C# programmer just starting out on GDI+.
Thanks
Chris
|
|
|
|
|
parrot123 wrote:
Can somebody indicate as to how I can go about creating such a mapping
Use a GIS system - many will have the ability to digitise data from non-digital sources (e.g. Paper maps)
parrot123 wrote:
can i use a database to store the points?
Most GIS systems will do this. Some are internal databases, others are more open.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Hello,
In my void main l have Application.EnableVisualSytles
This so that l can have an application that gives the XP appearance. This works wells for all the controls apart from the toolbar icons l have. The icons do not display. If l comment out Application.EnableVisualStyles, then the toolbars display the icons ok.
This visual style used to work on my application, and all of a suddern does not work now. I was doing some changes with main, but l don't think this has anything to do with the icons not showing.
Many thanks in advance,
Steve
|
|
|
|
|
i face a problem .
the problem is summerized as following:
1- i have 600 MB of text files.
2- each text file has specific symbol to indicate a racord like *1 (means reacod number 1 and so on).
3- i want to write a boolen query like (C# and programming) the result reaturned as following : text-file + record number that contains these terms
4- i read alot about inverted file and how big is it , and how we can compress it , but i didn't reach to anything
so can any one help or give me an idea to build an index from these text and that index doesn't exceed 10% of the origianl files and suppose a method to retrieve these records ...
thanks alot
DEvX
|
|
|
|
|
Hi,
I am having an interface that i have developed in C#. i am trying to execute another exe file (already generated by a cpp program) and that exe file will take a filename as input argument and should return an array to the calling program.
Now I am having 2 problems..
1) How to execute an exe file with passing arguments to it.
2) Am i able to read the return values from the exe file.
the below ones are doubts in a cpp file (already posted in c++ forum)..but if u have any ideas... u can suggest...
3) How can i return an array of data from a cpp file as a return value from a main().
any kind of suggestions are appreciated...
thanks in advance,
Suman
|
|
|
|
|
See System.Diagnostics.Process.Start .
Instead of making a mess with data returns why don't you dump the data into a file and read back from there?
The situation you are describing seems like a mess. Make sure your final solution is somewhat robust and reliable. Maybe use P/Invoke to instead of returning the data. Or maybe rewrite in c#??
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi Alex,
thanks for ur suggestions and i did the same way as u told, like dumping the data into a file and then reading the data from it.
But i am having a problem, when the process is started using Process.Start, my calling program is not waiting for the called process to complete before it goes to next step of execution. So, i am having some inconsistent data file by tht time as the called process take some considerable time to complete.
Is there any command to make the calling program to wait untill the called process is comepleted.
thanks in advance,
Suman
|
|
|
|
|
Yes. Take a look at System.Diagnostics.Process. Method WaitForExit .
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi Alex,
yeah... i figured it out... sorry i forgot to delete my previous reply, since i figured it out after i posted the reply to you.
Anyway thanks for ur help.
Suman
|
|
|
|
|
one that will be fun to work out and get good or interesting results, or to make an existing one better, need the ideas since I can't really think of any at the moment, thanxs in advance ;P:P;P
|
|
|
|
|
Something that interfaces with a airplane simulator. The neural networks job would be to make sure the plane flies in all weather.
Something that interfaces with Counter Strike. The neural networks job would be a killing machine
Alex Korchemniy
|
|
|
|
|
something simpler since I don't have alot of time since I need to be almost finished with it in a month since I will have to do alot of work..
|
|
|
|
|
navigating a maze?
there are no facts, only interpretations
|
|
|
|
|
Given a particular string, is there a way to tell whether it contains unicode characters? I know could test every character's range, but I'm wondering if there is some API call for this. I'm looking in string, System.Text.Encoding, and Globalization, but haven't found any likely suspects yet...
Matt Gerrans
|
|
|
|
|
Strings in .NET are stored as Unicode. The encoding only matters when reading and write from and to streams (text files, network streams, etc.).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I know that.
I'm adding lines to existing files. If the existing file is ASCII and I'm adding regular ASCII text, then everything's fine. However, if the line I'm adding has some Unicode characters (which may be the case), I want to change the file's encoding to Unicode and rewrite the thing out. (If the existing file is already Unicode, it is easy of course (except for this StreamReader bug that tells you it is UTF8)).
I've figured out how to do this aready, by going through all the characters and checking for any out of the 0-255 range, but I was wondering if there was an API call, or more idiomatic way of handling this.
Matt Gerrans
|
|
|
|
|
And why do you call it a bug? It sounds correct. UTF8 is an MBCS (multi-byte character set) that uses 7-bit characters as ANSI does, but 8-bit characters (i.e., the 8th bit is set) denotes Unicode codepoints. That's the beauty of UTF8 - it maintains backward compatibility so long as you don't use Unicode, and if you must it allows for that.
So, use the UTF8Encoding instead.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
It is incorrect if the file's BOM ("\xff\xfe") says it is Unicode (or UTF16) and the reader thinks it is UTF8 ("\xef\xbb\xbf"). So I call it a bug, because I think it is one. I've since noticed that if I use the StreamReader 's string constructor, it correctly identifies it as Unicode, but if I use the FileStream constructor it mis-identifies it as UTF8. So if I do this with a Unicode encoded file:
void SomeMethod( FileInfo info )
{
StreamReader reader = new StreamReader( info.OpenRead() );
System.Text.Encoding encoding = reader.CurrentEncoding;
string data = reader.ReadToEnd();
reader.Close();
data = Massage(data);
StreamWriter writer = new StreamWriter( info.OpenWrite(), encoding );
writer.write(data);
writer.Close();
}
I get a UTF8 encoded file as a result, which I don't want. On the other hand, if I do this:
void SomeMethod( FileInfo info )
{
StreamReader reader = new StreamReader( info.FullPath );
System.Text.Encoding encoding = reader.CurrentEncoding;
string data = reader.ReadToEnd();
reader.Close();
data = Massage(data);
StreamWriter writer = new StreamWriter( info.OpenWrite(), encoding );
writer.write(data);
writer.Close();
}
The file will be Unicode, as expected (and desired). Maybe the intermediate use of the FileStream causes the loss of the encoding?
Because these files are used by multiple platforms and programming languages (not all of which support MBCS), I want to simply use either ASCII or Unicode, but not UTF8 (or UTF7 or Unicode Big-Endian, etc.). I think there is not that much beauty in UTF8 (the "backward compatibility" also get hosed by use of extended ASCII characters, which usually comes from "backward" text files that were using drawing characters and the like), just unnecessary complexity, especially in these days of multi-gigabyte storage.
By the way, the original question was about detecting the presense of Unicode characters in a string (which, having 16-bit characters could contain some, or not); this would affect the case where the original file was ASCII, but a line with some Unicode characters were inserted into it. In that case, I just want to switch the whole file over to Unicode.
Matt Gerrans
|
|
|
|