|
Think I have solved it.
I have added a member to the control. The variable is of the dialog base class (in this case basedialog that is derived from form.) All my dialogs are derived from this basedialog class.
I create the dialog that is required, set the property and when the enter key is pressed, display the dialog from within the control code. Is this the correct way to do this.
Is there a better way?
|
|
|
|
|
I think, the better way is add event "ShowDialog_XY", which will be raised on [enter] key press and process event in method handled to this event.
The event arguments should contain result of dialog.
For example:
public class MyGrid : DataGridView{
protected virtual void ProcessEnterKeyPress() {
MyGridProcessEventArgs me = new MyGridProcessEventArgs();
this.OnProcessEnterKeyPress( me );
if ( me.Handled == false ) {
}
object result = me.Result;
if ( result == null ) {
}
this.ProcessResultOfEnterKeyPress( result );
}
protected virtual void ProcessResultOfEnterKeyPress( object result ) {
}
protected virtual void OnProcessEnterKeyPress( MyGridProcessEventArgs e ) {
EventHandler handler = this.ProcessEnterKeyPress;
if ( handler != null ) { handler( this, e ); }
}
public event EventHandler<MyGridProcessEventArgs> ProcessEnterKeyPress;
}
public class MyGridProcessEventArgs : EventArgs {
private bool handled;
private object result;
public bool Handled {
get { return this.handled; }
set { this.handled = value; }
}
public bool Result { get { ... } set { ... } }
}
public class Form1 : Form {
...
public Form1() {
this.InitializeComponents();
this.myGrid1.ProcessEnterKeyPress += this.myGrid1_ProcessEnterKeyPress;
}
private void myGrid1_ProcessEnterKeyPress( MyGridProcessEventArgs e ) {
}
}
Geniality is in simplicity.
|
|
|
|
|
Hi Jakub
Im trying to get this code to work so that I can undertand what it is doing. However I get errors compiler when implementing it and do not have suficient understanding to debug it yet.
The error tells me that
public event EventHandler ProcessEnterKeyPress
already exists in the base class
Error 1 The type 'BaseForms.BaseListDialog' already contains a definition for 'ProcessEnterKeyPress' C:\Beeftech\Modules\BaseForms\BaseListDialog.cs 69 35 BaseForms
What do I need to do to fix this.
ProcessEnterKeyPress seams to be defined by the datagridview from which my class inherits.
|
|
|
|
|
I want to get an instance of a running process and thruogh that instance I want to call its members in my application.
Noor
|
|
|
|
|
Play with System.Diagnostics i think you will get from this namespace
<l>Thanks and Regards
Sandeep
|
|
|
|
|
|
You can get the instance of currently running thread through System.Threading.Thread.CurrentThread but i dont think you can call its members a thread may contain several classes, functions etc. So i am not very much optimistic. You can dig deeper into that...
Regards,
Wasif Ehsan.
|
|
|
|
|
Hello!
wrote: I want to get an instance of a running process
using System.Diagnostics;
Your process would be:
Process myprocess = Process.GetCurrentProcess()
Process where you know the name:
Process[] someprocesspername = Process.GetProcessesByName("xxx");
wrote: and thruogh that instance I want to call its members in my application
Don't think this is posible that way!
All the best,
Martin
|
|
|
|
|
I have been researching all day on how to create an FTP site via a website. Our needs for out company is to be able to create FTP sites/virtual directories on the fly as a new team is created. I have some questions.
Most everything I have found works with System.DirectoryServices - which I understand works with Active Directories. Does the server hosting the site have to have Active Directories activated in order to use that dll?
We would prefer not to use Active Directories. Is there another api or method for generating a new FTP site and virtual directory that does not use Active Directories?
Thanks,
CK
|
|
|
|
|
Yes. If you are running Linux, most installations only require you to name a web accessible directory, 'ftp', for it to work as an ftp directory.
Hmmm. Maybe that's just unsatisfactory behavior or something.
|
|
|
|
|
The server hosting our sites is a Windows 2000 box - I appreciate the help you offered.
Our biggest concern is we don't want to use active directories on our web server. We do need to create FTP sites for each team for one of the sites we manage, but to date the only solutions I have seen use System.DirectoryServices and I am uncertain if I have to have active directories turned on in order to make the code work.
Can someone please help me understand how System.DirectoryServices works and if we need to use active directories or not.
If we do, is there another solution that would permit us to create an FTP site on the fly?
CK
|
|
|
|
|
I am trying to learn C# in a classroom setting. I have hit a barrier in trying to understand something.
In the following code sample under where it says weeklySalesAmount I get the message "The name 'weeklySalesAmount' does not exist in the current context". And under the mutators section where it says SetGrossPay it tells me "'Exercise_9_Chapter_4.Deduction.SetGrossPay(double)': not all code paths return a value"
public Deduction(string empName, double weeklySales)<br />
{<br />
name = empName;<br />
weeklySalesAmount = weeklySales;<br />
}<br />
<br />
public double SetGrossPay(double weeklySales)<br />
{<br />
const double GROSS_WEEKLY_PAY = .07;<br />
grossPay = weeklySales * GROSS_WEEKLY_PAY;<br />
}
In the next section where it says .netPay I'm told that "'Exercise_9_Chapter_4.Deduction.netPay' is inaccessible due to its protection level ",and that SetNetPay is "The name 'SetNetPay' does not exist in the current context".
Deduction employee = new Deduction(empName, wkSales);<br />
employee.netPay = SetNetPay();
I thought that I had everything done correctly according to the book. I have no idea as how to correct these problems. If anyone can help me, or at least steer me in the right direction, it would be muchly appreciated. Thank you.
-- modified at 17:04 Monday 26th February, 2007
|
|
|
|
|
Don't post programming questions in the lounge. I moved it for you.
JMOdom wrote: "'Exercise_9_Chapter_4.Deduction.SetGrossPay(double)': not all code paths return a value"
In fact, none of them return a value. That's what the message is telling you. You wrote a function that returns double, and you didn't return anything. Add return grossPage; at the end of the function and it will work. Also, if you have const values, it's a good idea to put them at the top, the whole point is that you can easily change them. Putting them in the function, you may as well hard code the value.
JMOdom wrote: 'Exercise_9_Chapter_4.Deduction.netPay' is inaccessible due to its protection level",
This means that netPay is private or protected. You should use public properties to expose private or protected members. You should expose only a get method if at all possible. Oh - if you didn't put an access modifier, it's private by default. What I mean is:
int n;
is private.
public int n;
is public, but you should instead do this:
private int _n;
public int N {
{
get { return _n; }
// set { _n = value; }
}
and only uncomment/add the set if you have to.
JMOdom wrote: and that SetNetPay is "The name 'SetNetPay' does not exist in the current context".
You've not shown us any code which involves a method called SetNetPay, so I can only assume this error is correct ( the method does not exist )
JMOdom wrote: I have no idea as how to correct these problems
I'm happy to help, but in each case, the compiler has told you what is wrong. As I help you through these issues, take note of what the terminology is, so you can learn how to use the error messages to work out how to fix your code
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
JMOdom wrote: "The name 'weeklySalesAmount' does not exist in the current context"
JMOdom wrote: public Deduction(string empName, double weeklySales)
{
name = empName;
weeklySalesAmount = weeklySales;
}
You need to declare variable "weeklySalesAmount". Probably at same place as variable "name".
JMOdom wrote: 'Exercise_9_Chapter_4.Deduction.SetGrossPay(double)': not all code paths return a value"
JMOdom wrote: public double SetGrossPay(double weeklySales)
{
const double GROSS_WEEKLY_PAY = .07;
grossPay = weeklySales * GROSS_WEEKLY_PAY;
}
And that is correct, SetGrossPay has return type of double, you should have return grossPay; before closing bracket. Or better, change return type from double to <c>void.
It sucks if examples in your book don't even compile. Not that surprising tho.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Thanks for the answers folks. Sorry I got into the area. All I can say is that I'm very new at this.
The answers given have helped greatly. Thanks again.
|
|
|
|
|
When I derive a generic collection from another custom generic class, the signature is creating a lot of problems for me.
English:
Build a GenColl (derived from keyedCollection ) containing elements of a GenElement.
- The compiler tells me to use an identifier in the signature and not the type?!?!
- and when I use place holder for types, it asks for reference namespace??
_______________________________________________________
The actual generic classes (simplified for easy reading)
// simple - works, the element or base construct
public class GenElement<Key, Value>{}
// this doesnt work, it is a collection of the above generic class
// I am not sure of what the signature should be... tried many combo
public class GenCollection <Guid, GenElement<<Key, Value>> : KeyedCollection<Guid, <Key, Value>>
{
// rest of the implementation blah blah
// with abstract over rides
}
^ ^
-The problem is, if I include the type place holders Key, Value in the
definition (public class GenCollection <Guid, GenElement<<Key, Value>> ), the complier complains that GenElement should be an identifier and not a type? if I removed the type place holders (public class GenCollection <Guid, GenElement>) its just fine, but doesnt see that GenCollection contains a GenElement
-can some help me resolve this. What should I do to get a generic collection GenCollection container that contains genElement (which further has two typePlace holders, key and value GenElement<<Key, Value>)?
-How do I, in the definition tie the Guid to the Key, is it possible?
-- modified at 10:28 Tuesday 27th February, 2007
|
|
|
|
|
Can you post it with the HTML tags turned off because all the < and > signs are garbled.
Perhaps what you want is (complete guess here because the code isn't visible):
public class GenElement<TKey, TValue> : KeyedCollection<TKey, TValue>
{
}
|
|
|
|
|
I turned off the HTML tags but how do I get the yellow?
|
|
|
|
|
Use "pre"
bla
bla
bla
Will not work if you "Ignor HTML tags..."
|
|
|
|
|
I'm sure most of you have had this problem. OpenFileDialog in Windows CE is restricted to the "My Documents" directoy level. Does anyone know of a quality go around that I can use. Need to get one fast for prototyping new portable PCs.
Functionally challenged...
|
|
|
|
|
Change th InitialDirectory property of the OpenFileDialog
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Hey guys whats going on ?
I have a form that I fill in with some info and I save them to my database, now I want to creat a crystal report and then print the information (Shown on the report), I'm new in this so could you help me out and give me any helpful link or article possible !!!
Thanx
Mr.K
|
|
|
|
|
|
Hi,
To use Crystal Report in .net is not much complex. steps involved are---
1. Add a new Window Form in your project.
2. Put Control From Tool box-->Crystral Report--->Crystal Report Viewer.
3. Click on Show Data Source Control from Standard Tool bar. It will show the existing data Sets if any. Otherwise generate the Data set.
4. Follow the next steps.......
5. Run the Report Viewer.
Now u can call this Report Viewer Form on the Click of any button.
Hope after trying this you will be able to view the Report.
All the Best !
Binod K.
|
|
|
|
|
Have anyone an idea how can switch between two properties(Resources.resx, Settings.settings)
|
|
|
|