|
So why don't you call SetCursorPos as that function does exctly what you want. It sets the mouse cursor to the specified location.
What you are doing is creating a mouse event. If nothing at that position you specified is able to respond to that event, then you'll see absolutely nothing.
Oh, but wait you would see something if you were looking at it. Everytime you klick somewhere on the screen or raise an event to that effect, the idle timer is reset to 0.
Cheers!
P.S. I just checked and it seems you can also raise mouse moved events read all about it here: mouse_event function[^], but you should know that the SendInput[^]function should be called instead.
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
I want convert code C# 2008 to code C# 2005, I did not understand the command C# 2008 to switch to C# 2005, see below is the error code can solve the error command do ? run the code in C# 2008 very good
[code]
private void textBox1_TextChanged(object sender, EventArgs e)
{
string str = textBox1.Text.Trim();
if (!string.IsNullOrEmpty(str))
{
// Error in here
Expression<func<customdata, bool="">> expr = n => GetCondition(n, str);
this.gridControl1.DataSource = this.lstCustomData.Where<customdata>(expr.Compile()).ToList();
}
else
this.gridControl1.DataSource = this.lstCustomData;
this.gridControl1.RefreshDataSource();
}
public class CustomData
{
// Error in here
public int col1 { get; set; }
public string col2 { get; set; }
public string col3 { get; set; }
public int col4 { get; set; }
}
[/code]
|
|
|
|
|
Member 2458467 wrote: this.gridControl1.DataSource = this.lstCustomData.Where<customdata>(expr.Compile()).ToList();
Dot net framework 2.0 doesn't include all of the LINQ / lambda and expression tree functionality. This came in with dot net 3.0
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
You can't just convert it: C# 2008 was V3.0 of the .NET framework, and supported features that the previous version just didn't know about at all - such as Linq and Lambdas.
Since you code contains lambda expressions and Linq methods, you will have to rewrite that complete section without either.
What's the problem? You wrote the code, so you should understand exactly what it does. So producing an "earlier version" shouldn't be a major challenge for you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
you say is true, It's using lambda expressions and LINQ which isn't supported in 2005 ... I was to learn write code how LINKQ and code no LINKQ but I do not know how to write without LINKQ (no LINKQ)
|
|
|
|
|
Member 2458467 wrote: do not know how to write without LINKQ
Sorry? You do - they certainly don't start any coding course with Linq / Lambdas! They start with the basics: loops and suchlike, then slowly build up to the more-complex-to-use code.
If you wrote the Linq stuff, you already know what to do to convert it back to "standard" code!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I have not written linkq, I am learn 2 type writing linkq and style of writing standards
|
|
|
|
|
Hello,
I am creating an application that allows to recover data in a database and display them in a datagridview .
Then I would like to insert the data recovered from the datagridview to another database that has the same structure .
Is what you have ideas to insert data into datagridview my new base.
Thank you for your help
|
|
|
|
|
Ibrahim.elh wrote: Is what you have ideas to insert data into datagridview my new base. I'd recommend "insert" queries.
Saving data into a database is a fairly common task that is well documented. What have you tried and where did you get stuck?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I Have try this:
con_local = new OdbcConnection();
con_local.ConnectionString = lc.Connexion_locale;
con_local.Open();
for(int i=0; i< dataGridView1.Rows.Count-1;i++)
{
adap_local = new OdbcDataAdapter("insert into thisdet2 values(" + dataGridView1.Rows[i].Cells[1].Value + "," + dataGridView1.Rows[i].Cells[2].Value + "," + dataGridView1.Rows[i].Cells[3].Value + "," + dataGridView1.Rows[i].Cells[4].Value + "," + dataGridView1.Rows[i].Cells[5].Value + "," + dataGridView1.Rows[i].Cells[6].Value + "," + dataGridView1.Rows[i].Cells[7].Value + "," + dataGridView1.Rows[i].Cells[8].Value + "," + dataGridView1.Rows[i].Cells[9].Value + "," + dataGridView1.Rows[i].Cells[10].Value + "," + dataGridView1.Rows[i].Cells[11].Value + "," + +")"+",", con_local);
}
ds_local = new System.Data.DataSet();
adap_local.Fill(ds_local);
i have an error :
The exception was not handled System.ArgumentOutOfRangeException
HResult = -2146233086
Message = Index was out of range. It must not be negative and must be less than the size of the collection .
Parameter name: index
Source = mscorlib
ParamName index =
|
|
|
|
|
Your code is vulnerable to SQL Injection[^].
NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
The ArgumentOutOfRangeException suggests that your rows don't contain 12 cells. (You're ignoring the first cell.) Did you actually mean to take the values from 11 cells, starting at index 0?
You're creating a new OdbcDataAdapter for each row in the grid, and then throwing away all but the last one.
You're specifying an INSERT command as the SelectCommand property of the data adapter.
Assuming you just want to insert the rows into the table, try something like this:
using (var connection = new OdbcConnection(lc.Connexion_locale))
using (var command = new OdbcCommand("insert into thisdet2 values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", connection))
{
var p0 = command.Parameters.Add("@p0", OdbcType.NVarChar);
var p1 = command.Parameters.Add("@p1", OdbcType.NVarChar);
var p2 = command.Parameters.Add("@p2", OdbcType.NVarChar);
var p3 = command.Parameters.Add("@p3", OdbcType.NVarChar);
var p4 = command.Parameters.Add("@p4", OdbcType.NVarChar);
var p5 = command.Parameters.Add("@p5", OdbcType.NVarChar);
var p6 = command.Parameters.Add("@p6", OdbcType.NVarChar);
var p7 = command.Parameters.Add("@p7", OdbcType.NVarChar);
var p8 = command.Parameters.Add("@p8", OdbcType.NVarChar);
var p9 = command.Parameters.Add("@p9", OdbcType.NVarChar);
var p10 = command.Parameters.Add("@p10", OdbcType.NVarChar);
var p11 = command.Parameters.Add("@p11", OdbcType.NVarChar);
connection.Open();
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
var row = dataGridView1.Rows[i];
p0.Value = row.Cells[0].Value;
p1.Value = row.Cells[1].Value;
p2.Value = row.Cells[2].Value;
p3.Value = row.Cells[3].Value;
p4.Value = row.Cells[4].Value;
p5.Value = row.Cells[5].Value;
p6.Value = row.Cells[6].Value;
p7.Value = row.Cells[7].Value;
p8.Value = row.Cells[8].Value;
p9.Value = row.Cells[9].Value;
p10.Value = row.Cells[10].Value;
p11.Value = row.Cells[11].Value;
command.ExecuteNonQuery();
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 25-Feb-15 10:54am.
|
|
|
|
|
Thank you !
I tried your code but does not include visual studio .cells []
|
|
|
|
|
Ibrahim.elh wrote: does not include visual studio .cells []
Sorry, I don't understand that comment.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I tested your code but I have an error
row.Cells[0].Value
cell is not included!!!
|
|
|
|
|
OK, that's closer, but it's still not clear. What's the exact error message?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Error 1 'object' does not contain a definition for ' Cells ' and no extension method ' Cells ' accepting a first argument of type 'object' was found ( a using directive or is an assembly reference ? missing)
|
|
|
|
|
That doesn't sound right - the Rows[i] indexer is supposed to return a DataGridViewRow , not an object .
Try replacing:
var row = dataGridView1.Rows[i];
with:
DataGridViewRow row = dataGridView1.Rows[i];
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Not work !
Error 1 Can not implicitly convert type 'object ' to ' System.Data.Odbc.OdbcParameter ' . An explicit conversion exists ( cast he is missing ? )
|
|
|
|
|
Once again, command.Parameters.Add(...) returns an OdbcParameter , not an object , so var p0 = command.Parameters.Add(...) should work.
If you were using an older version of .NET which didn't support var , you'd be getting a different error message.
Try specifying the types explicitly - for all of the lines:
var pN = command.Parameters.Add(...);
replace var with OdbcParameter :
OdbcParameter pN = command.Parameters.Add(...);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
it's not work !
i have a same error
|
|
|
|
|
Post the exact code you're trying to run, and the exact error message.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
using (var connection = new OdbcConnection(lc.Connexion_locale))
using (var command = new OdbcCommand("insert into thisdet2 values(cat,geo,etb,nobl,vend,fam,art,des,tare)", connection))
{
OdbcParameter cat = command.Parameters.Add("@cat", OdbcType.NVarChar);
OdbcParameter geo = command.Parameters.Add("@geo", OdbcType.NVarChar);
OdbcParameter etb = command.Parameters.Add("@etb", OdbcType.NVarChar);
OdbcParameter nobl = command.Parameters.Add("@nobl", OdbcType.NVarChar);
OdbcParameter vend = command.Parameters.Add("@vend", OdbcType.NVarChar);
OdbcParameter fam = command.Parameters.Add("@fam", OdbcType.NVarChar);
OdbcParameter art = command.Parameters.Add("@art", OdbcType.NVarChar);
OdbcParameter des = command.Parameters.Add("@des", OdbcType.NVarChar);
OdbcParameter tare = command.Parameters.Add("@tare", OdbcType.NVarChar);
connection.Open();
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
OdbcParameter row = dataGridView1.Rows[i];
cat = row.Cells[0].Value;
geo = row.Cells[1].Value;
etb = row.Cells[2].Value;
nobl = row.Cells[3].Value;
vend = row.Cells[4].Value;
fam = row.Cells[5].Value;
art = row.Cells[6].Value;
des = row.Cells[7].Value;
tare = row.Cells[8].Value;
command.ExecuteNonQuery();
}
}
|
|
|
|
|
I notice you haven't posted the error message.
The first and most obvious problem with that code is that you've replaced the parameter placeholders - ? in the query I posted - with what appears to be column names. That won't work.
The query needs to be:
using (var command = new OdbcCommand("insert into thisdet2 values(?,?,?,?,?,?,?,?,?)", connection))
You should preferably specify the column names explicitly. Assuming the names you used are the column names:
using (var command = new OdbcCommand("insert into thisdet2 (cat,geo,etb,nobl,vend,fam,art,des,tare) values(?,?,?,?,?,?,?,?,?)", connection))
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i have try with '?' but its not work
|
|
|
|
|
And the error message is?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|