|
I'd like to see a solution using LINQ!
Regards,
Rob Philpott.
|
|
|
|
|
DataSet ds = new DataSet();
string f = dateTimePicker1.Text.ToString().Trim();
string t = dateTimePicker2.Text.ToString().Trim();
ds = bl.Totall(f,t);
dataGridView1.DataSource = ds.Tables[0];
but there is error :"Cannot find table 0".
plz help me.
|
|
|
|
|
Member 11479040 wrote: ds = bl.Totall(f,t); ..and what's that supposed to be / to do?
|
|
|
|
|
Your code looks like it's expecting a DataSet to be returned from Totall. Whatever goes on in this method should create and append the DataTable to a DataSet that is returned out. BTW, you can drop the initialisation of your DataSet and just call
DataSet ds = bl.Totall(f,t); Also, please use better variable names. I assume f means from and t means to.
|
|
|
|
|
ds.Tables[0]
is where the exception is happening - ds has a an array of tables called Tables .
The exception is being caused by the array being empty. Why it's empty I can't know, this line:
ds = bl.Totall(f,t);
is the closest anyone can get. Setting aside the mis-spelling of "Totall" which you might want to fix, the bl.Totall(...) method isn't returning an array with anything in it - so that method is your problem. As you haven't provided the code for that method, we can't tell why it's returning an empty array. If you want further help, you'll need to post the code for that method and anything else associated with it that is relevant.
|
|
|
|
|
A was looking at now of the projects which describing how to simulate mouse movement and clicking on a certain coordinates.
I wrote this code based on what I learned from that project, it's actually the same..
but it's not working..
if this code is not correct
is there any way of doing that ? and how to implement that..
this the code
[DllImport("User32.dll")]
public static extern void mouse_event(MouseEventType dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
[DllImport("User32.dll")]
public static extern int SetCursorPos(int x, int y);
public enum MouseEventType : int
{
LeftDown = 0x02 , LeftUp= 0x04, RightDown= 0x08, RightUp= 0x10
}
and here is event handler, so when I click the button the mouse supposed to move to the coordinates..
private void button1_Click(object sender, EventArgs e)
{
SetCursorPos(300, 200);
mouse_event(MouseEventType.LeftDown, Cursor.Position.X, Cursor.Position.Y, 20, 20);
mouse_event(MouseEventType.LeftUp, Cursor.Position.X, Cursor.Position.Y, 20, 20);
}
any help in this,,
thanks
|
|
|
|
|
"but it's not working.."
That's not helpful.
What is it doing that you didn't expect, or not doing that you did?
Remember that we can't see your screen, access your HDD, or read your mind - we only get what you tell us to work with!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I only need to move the mouse to any coordinate after clicking on a button, only that is it!
I have a form application contains only a button, when I click the button (as you can see from the handler) I just need the mouse to be moved to any coordinate..
I know It may not difficult, but I couldn't do it till now..
I'm using VS 2012 ultimate..
thanks
|
|
|
|
|
And? What is happening when you run your code?
I really can't see your screen!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
if you mean the code which I written, nothing happens, it's not working at all. when I click the button nothing happens!!
if you mean what I need to get, it's only moving the mouse without touching any thing!!
|
|
|
|
|
|
Well, you could start by using .NET cursor movement:
Point current = Cursor.Position;
Cursor.Position = new Point(current.X + 50, current.Y + 10);
And then this works for me:
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
private const uint MOUSEEVENTF_LEFTDOWN = 0x02;
private const uint MOUSEEVENTF_LEFTUP = 0x04;
private const uint MOUSEEVENTF_RIGHTDOWN = 0x08;
private const uint MOUSEEVENTF_RIGHTUP = 0x10;
private void butClickMe_Click(object sender, EventArgs e)
{
Point current = Cursor.Position;
Cursor.Position = new Point(current.X + 50, current.Y + 10);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, Cursor.Position.X, Cursor.Position.Y, 0, 0);
} By putting a second button on the form, slightly right and down from the first, it gets clicked every time...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks OriginalGriff
the code is working ,,
but I have one more question
if I need for example to first LEFTDOWN and then move the cursor somewhere and then LEFTUP.
can we do that ?
As I know, MOVE mouse event is like
private const uint MOUSEEVENTF_MOVE = 0x0001
it's not working, and when I comment it the mouse events work fine..
how can we implement this ?
thanks,
|
|
|
|
|
The chances are that you can't do it quite like that: the way windows handles messages is probably why - they get queued, not executed immediately, so it's very unlikely that
Left down
Move mouse
left up will be executed in that sequence.
It's possible (I haven't tried) that this would work:
mouse_event(MOUSEEVENTF_LEFTDOWN, Cursor.Position.X, Cursor.Position.Y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, Cursor.Position.X + 100, Cursor.Position.Y + 100, 0, 0); It probably should.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I tried this one many times before
mouse_event(MOUSEEVENTF_LEFTUP, Cursor.Position.X + 100, Cursor.Position.Y + 100, 0, 0);
But the cursor not moves andy stay in the same position
and when I use this one
mouse_event(MOUSEEVENTF_MOVE, Cursor.Position.X, Cursor.Position.Y ,0, 0);
it also not moves the mouse
I tried to add some numbers to the coordinates but it's not working also,,
|
|
|
|
|
No, mouse_event won't move the mouse - it just signals that a mouse event occurred at the location, even if the mouse wasn't (and isn't) anywhere near it.
If you want the mouse to move, the operation to happen, and the mouse to move again, then you are going to have to use timers to move it, then issue a command, then wait for the next timer tick before doing the next event.
Just what are you trying to write here - I'm interested?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
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[^]
|
|
|
|
|