|
Can someone please explain me what the above 3 are & how are they to be used in development & how they interact with each other.
Thanks.
|
|
|
|
|
|
I am going to make it simply afterwords read more about it and download sample codes.
A DataGridView is use to display/report data the you have stored somewhere.
DGV is a gentlemen because display everthing regardless of the kind of datatable or dataset, meening that you dont need to create a "suit" that matches 100% your dataset scheme, it loads everthing!!!
For exemple, you can display/report data in crystal reports to, but here, you have to create a dataset scheme to fit your data!!!
A Dataset is a scheme, like: id(int),f_name(string),l_name(string),birth_date(date), it has to match the scheme of what you are loading, a sql databable for exemple, the fields as to be the same kind to fit!
A Datatable is part of a database, nothing here very fancy to know. Sometimes in C# in runtime you dont need to create the database and after the datatable, if you only need 1 datatable.
So, like you see DGV displays data from a datatable that as a dataset scheme, but in others objects like a crystal_report, you need to make a scheme to match the scheme of the datatable you are loading!!! got it???
Good Luck
nelsonpaixao@yahoo.com.br
trying to help & get help
modified on Thursday, October 23, 2008 8:58 PM
|
|
|
|
|
Hi All
Im trying to create a application that can connect connect to he exchange server. In my application i want to add a appoitment,Task List,Calendar. And all that need to connect to Exchange server.
if any one know can you please help me out
Thanks in advance
|
|
|
|
|
Hi, Im trying to define some custom events within one of my classes.
I have set the delegate and the event as follows:
<br />
public delegate void SegmentProgressUpdate();<br />
public event SegmentProgressUpdate ProgressUpdate;
That is just above my constructor.
It compiles, But at runtime when the event gets called I get the "Object reference not set to an instance of an object." Error.
Im sure i am doing something wrong, But i cant see what. I have read a dozen tutorials on custom events online, that all only have what i have above. And i have googled the error related to events but cant find a solution that works.
Does anyone have any idea?
|
|
|
|
|
Abydosgater,
I guessing you don't listen to the event. When you fire the event, check its not null.
if (ProgressUpdate != null)
ProgressUpdate();
Also, its best to try and stick to .net conventions when possible, so your delegate should take 2 params.
public delegate void SegmentProgressUpdate(object sender, EventArgs e);
Sender is the object calling the event, and the event args is the class with the information you'd like to pass, if you don't pass anything, just do a: EventArgs.Empty
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Thanks for the quick reply Gareth.
I have tried this, and it still doesnt work. It doesnt crash with the error but as you will see:
<br />
SegmentOne.ProgressUpdate += new Segment.SegmentProgressUpdate(SegmentOne_ProgressUpdate);
Im listening to the event, Thats in my main application, And i have changed it to this:
<br />
if (ProgressUpdate != null)<br />
{<br />
ProgressUpdate(this, System.EventArgs.Empty);<br />
}<br />
else<br />
System.Windows.Forms.MessageBox.Show("error segment.cs:109");
But now all it does is throw the error message box.
|
|
|
|
|
Abydosgater,
When do you listen to the event?, once you've created SegmentOne? or...?
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Yes once i have created the SegmentOne Object.
<br />
SegmentOne = new Segment(SegmentOneStart, SegmentOneEnd, this._webRequest);<br />
SegmentOne.ProgressUpdate += new Segment.SegmentProgressUpdate(SegmentOne_ProgressUpdate);
Hmm
|
|
|
|
|
You've got something screwy going on somewhere in your code.
This is a simple sample that has 2 events - one with custom event args.
public class TestA
{
public event EventHandler Property1Changed;
public event EventHandler<TestEventArgs> Property2Changed;
public int Property1
{
set { OnProperty1Changed(); }
}
public int Property2
{
set { OnProperty2Changed(value); }
}
protected virtual void OnProperty1Changed()
{
if(Property1Changed!=null)
Property1Changed(this, EventArgs.Empty);
}
protected virtual void OnProperty2Changed(int value)
{
if (Property2Changed != null)
Property2Changed(this, new TestEventArgs(value));
}
}
public class TestEventArgs : EventArgs
{
public TestEventArgs(int value)
{
m_Value = value;
}
private int m_Value;
public int Value
{
get { return m_Value; }
}
}
You can instanciate, subscribe to the events and set the properties to raise the events like:
TestA testA = new TestA();
testA.Property1Changed += new EventHandler(testA_Property1Changed);
testA.Property2Changed += new EventHandler<TestEventArgs>(testA_Property2Changed);
testA.Property1 = 1;
testA.Property2 = 2;
then the methods called above
void testA_Property2Changed(object sender, TestEventArgs e)
{
Console.WriteLine("Property 2 Changed to: " + e.Value);
}
void testA_Property1Changed(object sender, EventArgs e)
{
Console.WriteLine("Property 1 Changed.");
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Ive taken a look at that example, and i have added a full new test event to try it using the code above as an example.
public event EventHandler TestEvent;<br />
<br />
if (TestEvent != null)<br />
TestEvent(this, System.EventArgs.Empty);<br />
else<br />
System.Windows.Forms.MessageBox.Show("Event returned null");<br />
<br />
<br />
SegmentOne = new Segment(SegmentOneStart, SegmentOneEnd, this._webRequest);<br />
SegmentOne.TestEvent += new EventHandler(SegmentOne_TestEvent);
But as before, its just returning that the event is null and not calling it. even though i am listening for it.
|
|
|
|
|
Abydosgater wrote: within my constructor
If it's in the constructor - then the object instance may not yet created, and even if it is, the listener SegmentOne.TestEvent += new ... has not yet been attached so it will be always be null at that point.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I think the only way you can raise an event in the constructor that can be listened to is using a static event.
public class TestA
{
public static event EventHandler ConstructorCompleted;
public TestA()
{
OnConstructorCompleted(this);
}
protected static void OnConstructorCompleted(TestA instance)
{
if (ConstructorCompleted != null)
ConstructorCompleted(instance, EventArgs.Empty);
}
}
TestA.ConstructorCompleted += new EventHandler(TestA_ConstructorCompleted);
TestA testA = new TestA();
void TestA_ConstructorCompleted(object sender, EventArgs e)
{
if (sender is TestA)
{
Console.WriteLine("OK");
TestA.ConstructorCompleted -= TestA_ConstructorCompleted;
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
|
Thanks to Davie and Giorgi Dalakishvili i figured out the issue.
As Davie said above, It was a loop in the constructor so when it was getting called it had not yet been set to listen to.
So i moved the loop to its own Start() and it now works as below:
SegmentOne = new Segment(SegmentOneStart, SegmentOneEnd, this._webRequest);<br />
SegmentOne.ProgressUpdate += new Segment.SegmentProgressUpdate(SegmentOne_ProgressUpdate);<br />
SegmentOne.Start();
Thanks guys
|
|
|
|
|
Well, like the topic asks, is it possible to make a program in C#/VB.NET that can hide the mouse cursor in another program? (Like a mediaplayers videowindow)
Tried this:
[DllImport("user32.dll")] private static extern long ShowCursor(long bShow);
But you cant specify hwnd/handle, so it only works for the current window that belongs to my app.
So what im asking is:
Is it possible to hide the mouse cursor when its inside a window that belongs to another program?
|
|
|
|
|
Why not embedded the application inside yours and then use that to hide the cursor which you can do from .net.
|
|
|
|
|
what do you mean by embedding the application inside my application?
Its not a .NET app
|
|
|
|
|
if it's not a .net app why is it on a c# forum.....
however I know you can embed some thing in a win form, can you embed an entire application. Maybe not. I may be barking up the wrong tree, just thinking out the box.
Or you could have a transparent form on top of all the application and then just pass the click to it. ... just random ideas that may be rubbish, not something I've thougth too much about
|
|
|
|
|
I meant that my app is a C# app, but the app i eventually would embed is not.
The program im embedding is BSPlayer, a multimediaplayer which has a floating videowindow.
I tried embedding it, but without luck... And also, it needs to be fullscreen, so its sort of difficult :P
|
|
|
|
|
I saw a VB6 sample app that had excel completely embedded in it (to include full excel menus in the apps menu strip), but was unable to port it to VB.net, although that might've been a lack of experience since I'd only had a few months of work/.net experience at the time.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
dan neely wrote: excel completely embedded
I thought you may be able to do something like this but not sure how in c#
|
|
|
|
|
You can, you'd have to use DllImport.
You could first use SetWindowLong to remove the caption bar / border. Then use FindWindow to get a handle to the program you want to embed (or start the process yourself), then finally a call to SetParent to set the parent window of the external application to a panel or something inside your own application.
A simple test is to set the parent window of Internet Explorer to something like Notepad.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
The way you're post suggests it, you can't. You have no control over how the code of another app runs, and for the most part, how a foreign window behaves.
But, as the other poster said, it is possible to host the window of another app in your own application and control the mouse visibility in your own window. Though, using this technique can cause problems for the app being hosted. You may run into drawing problems in the hosted app, or other issues.
You need to create a window in your app, like a Panel control in a form. Just keep it a light-weight control. Then you need to get the window handle of the main window of the application and call a Win32 function called SetParent to change that window's parent to your Panel control's window. For example:
[DllImport("user32.dll", EntryPoint = "SetParent", SetLastError = true)]
private static extern IntPtr SetParent(IntPtr hwndChild, IntPtr hwndParent);
private void button1_Click(object sender, EventArgs e)
{
Process p = Process.Start("Notepad.exe");
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, panel1.Handle);
}
|
|
|
|
|
Does that include things like merging the captured applications menus into the host? The VB I'd seen a few years ago was IIRC several hundred lines. I'm wondering if it did more, or was just a stereotypical codethulu.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|