|
Hmmm, how would that work? I don't want to completely ignore the MouseLeave event of the control, I just want to ignore the MouseEnter event of the child controls, wouldn't the MouseLeave event of the user control still get fired?
|
|
|
|
|
Hi guyz,
I got a quick question regarding DataSets and RowState. In the
following code sample I populate a DataSet, then modifies two rows,
and call the DataRow.AcceptChanges(). But when i retrieve the
Rowstate of those edit Rows it says "UNCHANGED".
shouldn't be "MODIFIED". If not, then WHY?????
here is the code :
namespace DSEditEx
{
///
/// Summary description for dsClass.
///
public class dsClass
{
//private variable which represents a DataSet <ds>
private DataSet ds;
public dsClass()
{
//instantiate the <ds>
ds = new DataSet();
try
{
//Initialize ds
ds = new DataSet();
//define the first data table
DataTable tblCustomer = new
DataTable();
//define and add columns to ds
DataColumn custID = new
DataColumn();
custID.ColumnName = "CustomerID";
custID.ColumnName = "Customer ID";
custID.AllowDBNull = false;
custID.DataType =
System.Type.GetType("System.Int16");
tblCustomer.Columns.Add(custID);
DataColumn fn = new DataColumn();
fn.ColumnName = "FirstName";
fn.Caption = "First Name";
fn.AllowDBNull = false;
fn.DataType =
System.Type.GetType("System.String");
tblCustomer.Columns.Add(fn);
DataColumn ln = new DataColumn();
ln.ColumnName = "LastName";
ln.Caption = "Last Name";
ln.AllowDBNull = false;
ln.DataType =
System.Type.GetType("System.String");
tblCustomer.Columns.Add(ln);
//adding the table -> ds
ds.Tables.Add(tblCustomer);
//load some data into datatable 1
-> tblCustomers
DataRow r;
for(int i=0; i < 10; i++)
{
r = ds.Tables[0].NewRow();
r[0] = i;
r[1] = "Farhan_" + i;
r[2] = "Munir_" + i;
tblCustomer.Rows.Add(r);
}
}
catch(Exception ex) {
Console.WriteLine(ex.ToString()); }
}
//public method which illustrates how to edit
values
//in the datarow. How to check the state of the
DataRow
public void DemoDSEdit()
{
try
{
//we are going to modify Row[0]
DataRow editRow =
ds.Tables[0].Rows[0];
//we are going to modify the first
and last name
editRow[1] = "John";
editRow[2] = "Doe";
//Now check the state of all Rows
//Note we haven't commit any
changes yet
Console.WriteLine("Checking the Row
State");
for(int i=0; i <
ds.Tables[0].Rows.Count; i++)
Console.WriteLine("State of
Row[" + i + "] : " + ds.Tables[0].Rows[i].RowState.ToString());
//Now Commit changes and again
check the State of Row
Console.WriteLine("\nCommitting
Changes and Checking the RowState");
editRow.AcceptChanges();
for(int i=0; i <
ds.Tables[0].Rows.Count; i++)
Console.WriteLine("State of
Row[" + i + "] : " + ds.Tables[0].Rows[i].RowState.ToString());
//Modify the Row[0] again
editRow = null;
editRow = ds.Tables[0].Rows[1];
editRow[1] = "Jane";
editRow[2] = "Munir";
Console.WriteLine("\nCommitting
Changes and Checking the RowState");
editRow.AcceptChanges();
for(int i=0; i <
ds.Tables[0].Rows.Count; i++)
Console.WriteLine("State of
Row[" + i + "] : " + ds.Tables[0].Rows[i].RowState.ToString());
}
catch(Exception ex) {
Console.WriteLine(ex.ToString()); }
}
}
}
----------------------------------------
OUTPUT is :
----------------------------------------
Checking the Row State
State of Row[0] : Added
State of Row[1] : Added
State of Row[2] : Added
State of Row[3] : Added
State of Row[4] : Added
State of Row[5] : Added
State of Row[6] : Added
State of Row[7] : Added
State of Row[8] : Added
State of Row[9] : Added
Committing Changes and Checking the RowState
State of Row[0] : Unchanged
State of Row[1] : Added
State of Row[2] : Added
State of Row[3] : Added
State of Row[4] : Added
State of Row[5] : Added
State of Row[6] : Added
State of Row[7] : Added
State of Row[8] : Added
State of Row[9] : Added
Committing Changes and Checking the RowState
State of Row[0] : Unchanged
State of Row[1] : Unchanged
State of Row[2] : Added
State of Row[3] : Added
State of Row[4] : Added
State of Row[5] : Added
State of Row[6] : Added
State of Row[7] : Added
State of Row[8] : Added
State of Row[9] : Added
|
|
|
|
|
If you want the rows to remain as MODIFIED, do not call AcceptChanges(). By calling AcceptChanges() you are commanding the data row(s) to end the current edit.
|
|
|
|
|
The idea is that you perform the editions on the rows (add, delete, modify) and then, somewhere else, you check which rows have been modified and save only those to the database. You then call AcceptChanges . Then, after the next set of changes, only the newly-changed rows will require saving to the real database.
If you use a data adapter, it automatically calls AcceptChanges in Update after updating the database.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I m having a problem, where i need to display shared folders of a computer in C#. Like i enter a computer name and it has to display shared folders in windows explorer. i don't know how to do it? can anybody guide?
Amar
|
|
|
|
|
You'll need to utilize the Windows Shell APIs. This site has several articles on how this is done, search for 'shell' C# articles and you should get a few hits.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Conversation With a Muslim
Judah Himango
|
|
|
|
|
I wonder if u can help me in solving the following problem:
I want to divide a number by 10 and get the result as the highest number.
Let me explain with following examples:
13/10 = 2 and
27/10 = 3
How can I achieve this
thanks
|
|
|
|
|
Math.Round( (a / 10) + .5 ) ?
David
|
|
|
|
|
How about (int)((n+9)/10) ?
You can even skip the (int) if your n already is an int...
mav
|
|
|
|
|
Not knowing C# I can't give you the proper code, but in pseudo-code:
If (x - int(x)) > 0.00
return int(x) + 1
else
return int(x)
Unlike the rounding function, which will round down as well as up, this will return either the original input, if it is an integer, or the next higher integer if it contains any fractional part at all. You may still get some goofy errors, though, because the input might have some small fractional part due to previous calculations. There are ways to get around that, but they may not be necessary depending upon your application.
"...putting all your eggs in one basket along with your bowling ball and gym clothes only gets you scrambled eggs and an extra laundry day... " - Jeffry J. Brickley
|
|
|
|
|
|
gee *cough* I'll join, assuming x is an int..
int n = (x / 10) + (x % 10 > 0 ? 1 : 0);
*lame around* \o/
|
|
|
|
|
While walking at the abyss of insanity, I found out, you can use something completely senseless, far away from anything that could be called useful. Evalute strings.
int x = 27;<br />
int n = 0;<br />
string seperator = System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;<br />
<br />
double d = ((double)x / 10.0d);<br />
string s = d.ToString("F1");<br />
<br />
if (!s.Substring(s.IndexOf(seperator) + 1, 1).Equals("0"))<br />
{<br />
d += 1.0d;<br />
s = d.ToString("F1");<br />
}<br />
<br />
n = int.Parse(s.Substring(0, s.IndexOf(seperator)));
|
|
|
|
|
Daniel, you frighten me!
mav
|
|
|
|
|
You are outta control!
|
|
|
|
|
Umm.. yes, I got it out of the abyss of insanity, I'm walking quite close to it but usually don't use anything from there
Even if it works, it's awful, but it works
I also like the ASM version from Niklas Ulvinge
|
|
|
|
|
Wouldn't this be machinecode optimised:
n >> 1;
n /= 5;
n++;
In asm it would be like:
;number in AL
SHL AL,1 ;2 clocks
MOV BL, 5 ;4 clocks
DIV BL ;0-90 clocks
INC AX ;2 clocks (saved one clock by using AX insted of AL...)
;
;I'm not familiar with how much the div instruction takes in time but
;since it is only 5 I think's it's not much.
;
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
Thanks for many ideas. This is what worked for me:
Math.Ceiling(13.0D / 10.0D);
Only if the values inside Ceiling(...) are Double and not int
|
|
|
|
|
Hi,
I'm reading in a DBase V database with an ODBC dataAdapter. This went well with the first version of the database, but I got an update friday and this one crashes. The strange thing is, it goes to the catch block on the fill method and crashed on the Exception itself.
so :
try{<br />
adapter.Fill(dataset);<br />
}<br />
catch(Exception e1){<br />
}
the error is a nullreference exception of e1??
Could it be the database is corrupt because it was zipped? I put the previous version back, but it still crashes and I didn't change any code in the meantime.
the execute statement is just a Select * from table .
I hope somebody can help me,
tnx!
No hurries, no worries.
|
|
|
|
|
i want to write a program that count data loading from internet, how can i do it?
|
|
|
|
|
What do you mean by "count data"? This is no where near enough information to answer your question.
|
|
|
|
|
I mean, i want to know how much data (in bits or bytes) that my computer has been loading from the internet each time i'm online.This program helps me to calculate how much money i have to pay for using Internet each month.Experts help me please !! i'm so poor
|
|
|
|
|
How to set list view item (detailed view) as selected and focused?
thanks
|
|
|
|
|
ListViewItem it = listView1.Items[3]; // pick an existing item to select
it.Selected = true; // select item
listView1.Focus(); // focus the listview
mav
|
|
|
|
|
Hello!
I am trying to query an open relay database (ordb.org) using a DNSquery. I have constructed a DNSquery and it works against any regular DNSserver but when I use the query against ordb.orgs database I never recieve any answer. So does the regular DNSqueries differ from the ones i should send to the open relay database? From what I have learned it shouldn't.
The FAQ for using DNSqueries at ordb.org is located here http://www.ordb.org/faq/#usage_dns[^]
Any help is more than welcome!
Best regards
Kristofer
|
|
|
|