|
See System.Windows.Forms.Help.ShowHelp
|
|
|
|
|
Hi All,
I have a smart part views which is calling a user control named "A". I want to call a another user control named "B" from previously loaded user control "A". Is that possible or otherwise i have to change the user control "A" to a smart view.
Please anyone help me in this, if possible with a sample code...
Thanks in advance,
Uma Shanker.K
|
|
|
|
|
when i double click in listview i want to do something i have 4 item i listview
but how i get item line 1 is id? line2 id? but idont know to use method
if (listview1.???????? = =1) { do somthing }
srry i begin
|
|
|
|
|
you can use listView.Items[...] property generally
in double click
and ListView.SelectedItems[...] Property or List.View.SelectedIndices[...] which the first one returns the selected ListViewItem and another one returns the index of the selected ListViewItem
and if you do not use multi selection you can simply access to the selected Item like
ListView.SelectedItem[0]
<br />
<br />
void listView1_DoubleClick(object sender, EventArgs e)<br />
{<br />
MessageBox.Show((sender as ListView).SelectedItems[0].Text);<br />
}<br />
good luck
|
|
|
|
|
|
can you give some hints about what exactly you mean about id?
Using the ListBox is very similar except it has too more ListBox.SelectedItem and ListBox.SelectedIndex Properties and another difference is it will return an object which must be casted to what you put inside for using it after retrieving from the list
and about showing things in ListBox
when you add something in listbox it simply use your object's ToString method for showing that in the list So all things you want to show from your class in the listBox must be set into overridden version of ToString method so it can show that.
Hope this one helps
|
|
|
|
|
As title really, i have an app with the ability to drag an item from a list box onto another grid type control, i can drag and drop no problem, i can also get the x,y coords of the mouse within the control when not dragging, but i need to get them when i have dropped the item onto the grid control. the problem is, the coords i am getting are not the withing the control but the screen ( i think ) any ideas how i can covert to the controls coords or how to get the coords from the control ??
Thanks in advance
Lee
|
|
|
|
|
hi
Point point = MyControl.ScreenToPoint(new Point(e.X, e.Y));
regards
|
|
|
|
|
i cannot see a function ScreenToPoint i have PointToScreen and PointToClient but not the otherway round ?? am i missing something here ??
Thanks
|
|
|
|
|
you want PointToClient
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
thanks, i finally sussed it after reading the first response... i just used
Point pt = Control.PointToClient( new Point( e.X,e.Y ) );
Thanks for the responses..
|
|
|
|
|
Hi All,
I have some block that occur in my catch ( try...catch ), this block is repeats a lot of time ( with different message but beside this message all the rest are the same ).
In C++ i would replace this block with some #define - but in C# i cant use ( of course ) this define.
My question is is there is something else that i can use to save line code in my project ?
Can i use something else beside writing all those 4 line in the block again and again and .... again....
I know that i can write some method and call it all the time - but i looking some other way.
Thanks for any help
|
|
|
|
|
No there is not.
"#define IDENTIFIER" is available for conditional stuff, there is no DEFINE
for code substitution.
go with the method !
And if you want to show the exception, show it in its entirity, that is
with ToString(), everything else sucks.
What's in those four lines anyway ?
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Yanshof wrote: I know that i can write some method and call it all the time
Well, why not?
Yanshof wrote: but i looking some other way
Why? What advantage do you think you will get?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Colin Angus Mackay wrote: Why? What advantage do you think you will get?
#define in C/C++ is a code obfuscater. Obfuscated code is job security.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
You can use #if, #else if #else inside the code, and you can #define some constants either at the very beginning of the file or in the project properties
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Use a method and/or derive your own type of Exception.
On the other hand... The "C preprocessor" can be used with any type of text file, not just C/C++ source files. I do use it with C#, but only to prove the point.
|
|
|
|
|
Hi All,
I am developing an application where a vehicle's route will be tracked by Microsoft MapPoint. Recently, it gives me an error message box - "Server Busy" and it has 2 option buttons "Switch to" and "Retry".
I have searched in Google and they say that it occurs when - the COM object(here MSMapControl) is not responding within a time period. They all suggest to set
"app.OleRequestPendingTimeout" to a higher value. But this is in Visual Basic and this object is not supported in C#.
Can anyone tell me how can i do this in C# ?
Thanks
Chayan
|
|
|
|
|
Hi everyone,
I'm looking for a nicer way to invoke methods. The following code is called by:
Fetch(someObject, "GetCustomer", 1) .
The ugly thing about this is that the name of the method is passed as a string. Is there a way to support something like:
Fetch(someObject.GetCustomer, 1) ?
I tried to use generic delegates, but had trouble with params object[] args as parameter and with the encapsulation inside the Fetch method...
Thanks in advance
glFrustum
<br />
public object Fetch(object target, string methodName, params object[] args)<br />
{<br />
return target.GetType().InvokeMember(<br />
methodName, BindingFlags.InvokeMethod, <br />
null, target, args);<br />
}<br />
|
|
|
|
|
|
Thanks, but this article describes what I'm trying to avoid
(Passing methods as string)
|
|
|
|
|
You can dynamically load an assemble and then invoke a method in it.
Step one. Create an interface that defines the methods you want to call.
Step two. Create an static readonly variable of that interface.
Step three. Use the variable to call methods.
Microsoft calls this a strategy.
If you want to be totally dynamic. There is a methodinfo class that you can get all the methods from a type.
Hope that helps.
Ben
|
|
|
|
|
I was looking for a solution that doesn't affect the called methods;
something like a generic delegate that 'eats' everything would be fine!
Don't you have to use the method name as string to get the MethodInfo?
I tried to avoid this.
|
|
|
|
|
glFrustum wrote: I'm looking for a nicer way to invoke methods. The following code is called by:
Fetch(someObject, "GetCustomer", 1).
The ugly thing about this is that the name of the method is passed as a string. Is there a way to support something like:
Fetch(someObject.GetCustomer, 1)?
Im still searching for the reason why you think the latter is preferable to the former. In answer to your question, if all the methods you want to call from your Fetch method have the same signature you could use delegates insstead of reflection (which identifies methods/properties the same way you do - by name).
eg. Say this is a data layer you are writing and the Fetch method is responsible for getting data from a vasiety of methods which follow this signature:
DataSet SomeGetDataMethod(object [] parameters)
you would define a delegate along the lines of
public delegate DataSet GetDataDelegate(object[] parameters);
You would then define your Fetch method as follows
public DataSet Fetch(GetDataDelegate method, object[] parameters)
{
method.Invoke(parameters);
}
Then to call this method you could have:
object[] parameters = new object{ 1 };<br />
Fetch( new GetDataDelegate(someObject.GetCustomer), parameters)
you could then pass a delegate to any of your data methods into this fetch method without using reflection.
Personally id stick with reflection!
|
|
|
|
|
Thanks for the feedback. I'd prefer the latter, because the string could cause troubles (renaming of methods etc.).
Also, using
someDelegate.DynamicInvoke(args)
could be faster than
target.GetType().InvokeMember(methodName, BindingFlags.InvokeMethod, null, target, args); .
The problem is that the methods do not have similar signatures and I don't know how to implement a generic delegate that can handle all types of signatures (if this is even possible...).
Please let me know if you have any idea...
thx
|
|
|
|