|
thx dave;
the code I supplied was the code that works for the form mouse move event. The code that I am trying to get working is...
private void Form1_Load(object sender, EventArgs e)
{
this.MouseMove += new MouseEventHandler(this.panel1_MouseMove);
}
//--------------------- Mouse Move ------------------------------
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
Point mousePoint = PointToClient(MousePosition);
string msg = string.Format("X:{0}, Y:{1}",
mousePoint.X,
mousePoint.Y);
lblMousePosition.Text = msg;
}
thx
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
I think you are still not getting the point.
If this is the code which you have used –
private void Form1_Load(object sender, EventArgs e)
{
this.MouseMove += new MouseEventHandler(this.panel1_MouseMove);
}
//--------------------- Mouse Move ------------------------------
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
Point mousePoint = PointToClient(MousePosition);
string msg = string.Format("X:{0}, Y:{1}",
mousePoint.X,
mousePoint.Y);
lblMousePosition.Text = msg;
}
Notice that you are using line –
this.MouseMove += new MouseEventHandler(this.panel1_MouseMove);
In the above line ‘this’ represents form, and not a panel. So still you are not getting a handler for panel control.
Replace the above mentioned line with –
panel1.MouseMove += new MouseEventHandler(panel1_MouseMove);
Notice that I am using ‘panel1.MouseMove’ and not ‘this.MouseMove’. Here panel1 is name of my panel control, if you have used a different name, you should replace it with the name of your panel control.
-Dave.
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
Thanks again Dave;
I think that I have found the problem this event does not fire. Not sure why but the Form Load nevers fires therefore mouse move is not working
...
private void Form1_Load(object sender, EventArgs e)
but it does not...
THX
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
So in order to get the Form Load event to work I added this to the Designer of the form
this.Load += new System.EventHandler(this.Form1_Load);
do I need to do this or should VS add this for me when I add the event??
Sorry for these "bone-head" questions but this is the kind-of stuff VB would have added automatically and I'm not sure what has to be added when.
THX
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Can I restrict a template parameter to primitive (or unmanaged) types only? Is it possible to enforce this condition so that I can take a pointer to it?
class Example<t> where T : struct {
T* p;
}</t>
I get an error because T is a managed type. I understand this, but is there a way to tell the compiler that it's a native type (e.g. int or double )?
|
|
|
|
|
|
|
DataTable dt = new DataTable("SomeTable");
string[] tokens;
dt.Columns.Add("ID",typeof(int));
dt.Columns.Add("Name",typeof(string));
StreamReader sr = new StreamReader("C:\\SomeFile.csv");
while (!sr.EndOfStream)
{
tokens = sr.ReadLine().Split(',');
if (tokens.Length == 2)
dt.Rows.Add(tokens);
string strExpression = "ID = 1";
DataRow[] dr = dt.Select(strExpression);
MessageBox.Show(dr[0].ToString());
Can you tell me how would you build and use a select expression and use it in DataTable.Select()
Please, dont link me to some website, but give me your experience or at least try it and let me know how it works.
Many thanks guys!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
i've tried your code but no error found
here my code
private DataTable CreateDataTable()
{
DataTable result = new DataTable();
result.Columns.AddRange(new DataColumn[]{new DataColumn("ID", typeof(int)), new DataColumn("NAME")});
return result;
}
public List<string[]> CreateList()
{
List<string[]> result = new List<string[]>();
for (int i = 0; i < 100; i++)
{
string[] data = new string[] { string.Format("{0}", i + 1), string.Format("data_{0}", i + 1) };
result.Add(data);
}
return result;
}
private void button1_Click(object sender, EventArgs e)
{
DataTable dtb = CreateDataTable();
List<string[]> result = CreateList();
for (int i = 0; i < result.Count; i++)
{
dtb.Rows.Add(result[i]);
}
dataGridView1.DataSource = dtb;
try
{
string strExpression = "ID = 1";
DataRow[] dr = dtb.Select(strExpression); MessageBox.Show(dr[0].ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
Thanx mate!
But I still need it to be as I wrote it "DataTable is filled out of a file that makes it ambiguous to decide what type the value is" as seen from my example, can you please try it with my exact code and tell me what modification I would need?? Cuz I think the problem is in the way I'm storing data not in filtering it!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hello
I have a program that is connecting to an excel file, run a query and fill a dataset,
My program is running ok in my computer (windows XP pro) but when I try to run in a windows 2000 computer I got an Exception with the excel file,
Please could you help me?
Thanks
This is the code for my class
class AS400PN
{
private OleDbConnection xlCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "\\ITEMS.xls;Extended Properties=Excel 8.0;");
private OleDbDataAdapter xlDataAdapter;
private DataSet xlDataSet = new DataSet();
public int iNumRecords = 0, iNumAllRecords = 0;
public string sRev, sDescription;
public AS400PN() { }
public void LoadParams(string PartNumber)
{
try
{
File.Copy("\\\\serverm\\public\\items\\items.xls", System.Windows.Forms.Application.StartupPath + "\\items.xls", true);
xlCon.Open(); //Open OLE/DB connection to Excel
xlDataAdapter = new OleDbDataAdapter("SELECT * FROM [ITEMS" +"$] WHERE ITNBR='" + PartNumber + "'", xlCon);
xlDataSet.Clear();
xlDataAdapter.Fill(xlDataSet);
iNumRecords = xlDataSet.Tables[0].Rows.Count;
xlCon.Close();
}
catch(Exception exc)
{
throw (new Exception("Error reading Excel file"));
}
finally
{
xlCon.Close();
}
}
Life is Great, and kids the best
|
|
|
|
|
R.A.C wrote: I got an Exception with the excel file
What is the exception you get (particularly what is in exc )? Be a bit more verbose and someone may be able to help.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Paul,
I found my error with this application
By mistake I was not displaying the exc Exception, I was only displaying my own error message
After your question I notice my error and found that computer with windows 2000 had an old version of the MDAC,
I just need to run an early version and everything works OK,
Regards
Rafael
Life is Great, and kids the best
|
|
|
|
|
R.A.C wrote: windows 2000 had an old version of the MDAC
Oh yeah, those can be sometimes subtle
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi.
I want substitute of this code
this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)( ()=>
{
this.ProgressBar.Value = e.ProgressPercentage;
}));
Is this Lambda expressions ?
Thanks in advance.
|
|
|
|
|
Mohammad Dayyan wrote: Who can help
Google
|
|
|
|
|
Yes, it is a lambda expression.
By the way, that the () => means that it has no parameters.
And why do you want to substitute it? Lambda expressions feels more natural than delegates' syntax.
Eslam Afifi
|
|
|
|
|
Hey Eslam.
Thank you very much.
Eslam Afifi wrote: And why do you want to substitute it? Lambda expressions feels more natural than delegates' syntax.
You're right.
But I don't understand lambda expression more , thus I'd like seeing substitute it for more learning .
|
|
|
|
|
You can write
(Action)(() => this.ProgressBar.Value = e.ProgressPercentage) //no casting to Action needed by the way
as
delegate() { this.ProgressBar.Value = e.ProgressPercentage; }
This article[^] helped me understand lambda expressions, linq ...
Eslam Afifi
|
|
|
|
|
Thank you very much my friend
|
|
|
|
|
You're welcome
Eslam Afifi
|
|
|
|
|
Hello,
I am trying to understand the CER feature, but I am not very confident that I understand it well. I have read a number of articles about it, but I still need to check whether I understand it correctly. I hope you could help me.
First, I apologize for this long post. I thought it is necessary to clarify my question. I'm thankful for your patience.
I am implementing a SafeHandle , and the release code looks like this:
class MySafeHandle : SafeHandle {
protected override bool ReleaseHandle() {
MyClass.freeHandle(handle);
return !MyClass.CheckErrors(false);
}
}
class MyClass {
internal static extern void freeHandle(MySafeHandle handle);
internal static extern bool checkExternalErrors();
internal static bool CheckErrors(bool throwExceptionOnError) {
if (!checkExternalErrors()) return false;
if (throwExceptionOnError) throw new Exception();
return true;
}
}
I'm not sure what to label freeHandle , checkExternalErrors and CheckErrors . freeHandle wouldn't tell whether there is an error; I have to call CheckErrors for that. But it will never throw an exception either, so I'm thinking it should be labeled [Cer.Success] .
Meanwhile, CheckErrors may throw an exception, depending on the throwExceptionOnError parameter. So I think this should be labeled [Cer.MayFail] . But I don't really know... wouldn't that violate the CER on ReleaseHandle ? Also what should I label checkExternalErrors ? Does it not need a label? Or does it still need [ReliabilityContractAttribute(Consistency.WillNotCorruptState)] ? I really feel confused!
Thanks a lot for your patience! Even if you don't answer, I'm grateful that you read this post to the end.
|
|
|
|
|
hello,
my problem is that i am working on a window app in c#.
i have three buttons on my form.now while selecting with tab button i want to
fire button1_click or button2_click event when we press enter.for 1 button it can
be easily done by form's accept button property .but how can i do it for all
|
|
|
|
|
If any button is focused and you press enter, its click event is automatically fired.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Hi,
First I will apologise for not answering your exact question but here is another way to achieve your goal.
Did you know that the standard windows keyboard method for simulating a keypress on the button that has focus is the space bar. Change focus from button to button with the tab key and then use space to press the button, no programming required on your part!
Alan.
|
|
|
|