|
|
Hi Richard,
I am testing various methods and events of the PropertyGrid class but could not capture the double click an event, nor the automatic generation of the event name using the method CreateUniqueMethodName.
I need to intercept this action to open my dialogue will be informed where the event code.
Can you be more specific?
Thanks
|
|
|
|
|
Your original question stated: I need to capture the double mouse click events If you check the documentation there is a method called OnMouseDoubleClick [^] and an event called MouseDoubleClick [^]. Is there some reason why neither of these will do the job?
|
|
|
|
|
I had already tested the events MouseDoubleClick and both DoubleClick and not fired.
myPropertyGrid_MouseDoubleClick void (object sender, MouseEventArgs e)
{
MessageBox.Show ("MouseDoubleClicked");
}
myPropertyGrid_DoubleClick void (object sender, MouseEventArgs e)
{
MessageBox.Show ("DoubleClicked");
}
|
|
|
|
|
It would appear that the documentation is not very clear. Since almost everything within the property grid is a control, they are all consuming the mouse clicks. I found the only place where it responds is by clicking in the small space between the main property table and the description below it.
|
|
|
|
|
Sorry Richard, but did not. I clicked all over the place and does not fire any of the two events (DoubleClick / MouseDoubleClick).
|
|
|
|
|
It's a very small gap between the two windows. When the mouse is over it the cursor changes to a little dark horizontal line with an up and down arrow on it.
|
|
|
|
|
Really, I see! Among the properties panel and the details of the component
|
|
|
|
|
Hello
I need some help. I am newcomer in C#.
The application is the PhoneBook. All the data serializable and stored in the List<>. Ithe main idea is to realize MVC pattern.
The question is how to implement events for deleting and editing contacts? Event for adding a contact is already exist and works.
To delete contact - inside the buttonDeleteContact_Click handler I need to get a selected object, than wrap it in DeletePersonEventArgs
and call the event (identical to AddClicked) DeleteClicked that will contail a code that delete a contact.
1. How to describe a type of Delete event ?
internal class DeletePersonEventArgs : EventArgs
2. What should be in
buttonDeleteContact_Click handler ?
3. What should be inside controller's method that handles the DeleteClicked event?
void form_DeleteClicked(object sender, DeletePersonEventArgs e)
The same issues for Update code.
Could you please provide a code example for this events and help me to realize this logic.
https://skydrive.live.com/redir?resid=45CC0C0F1CD563C9!281&authkey=!AIbigiVNGjyCQ9w here is the link for the source code - VS 2012
|
|
|
|
|
I am using distance method in the DBGeography to find the places within given raduis... but now I need to figure out whether the given geo coordinates (Lat, longitude) are whether within given geo fence or not... geo fence could be any shape (circle, square, ploygon etc... My question is that is there any classes or methods in C# to do that?
Thanks.
|
|
|
|
|
Effectively you're just going to do a PointIn... test. Given that you can represent pretty much anything as a polygon, you could use the techniques presented in this[^] article. It's fairly straightforward to create your own implementation.
|
|
|
|
|
this is in my c++ file
public ref class Class1
{
public:
int read_file
(const char * file_path,
hdf_call_vars_t & ret_vals) ;
};
and from c# I call it like so (unsafe code)
hdf_call_vars_t ret_vals;
string str = "C:\\a.h5";
byte[] bytes = Encoding.ASCII.GetBytes(str);
fixed (byte* p = bytes)
{
sbyte* sp = (sbyte*)p;
DoAT.Class1 cl = new DoAT.Class1();
cl.read_file(sp, ref ret_vals);
It does not compile sayiing the c++ is expecting a pointer to a structure. I thought making it an & is the same as passing by ref?
Input appreciated.
thanks,
sb
p.s. the c++ is a managed dll and I add it as a reference in the c# program.
modified 12-Feb-13 23:53pm.
|
|
|
|
|
bonosa wrote: It does not compile sayiing the c++ is expecting a pointer to a structure. I thought making it an & is the same as passing by ref? It is indeed passing by ref. How is your hdf_call_vars_t looks like? For me the following code compiles and runs fine.
struct hdf_call_vars_t {
int foo;
};
public ref class Class1 {
public:
int read_file(const char * file_path, hdf_call_vars_t & ret_vals);
};
int Class1::read_file(const char * file_path, hdf_call_vars_t & ret_vals)
{
Console::WriteLine(ret_vals.foo);
return 1;
}
int main(array<System::String ^> ^args)
{
hdf_call_vars_t instance;
instance.foo = 10;
Class1^ c = gcnew Class1;
c->read_file("A string", instance);
return 0;
} If you are using C++/CLI, you don't have to use unsafe code in C#. Just wrap the C++ specific code in C++/CLI and return well defined managed objects which can be consumed directly from C#. After all, that's what C++/CLI is best at.
Best wishes,
Navaneeth
|
|
|
|
|
thank you Navaneeth.
The struct is
[StructLayout(LayoutKind.Sequential, Pack = 1)]
/* Returned values from read_file */
unsafe struct hdf_call_vars_t {
public channel_vars p_vars;
public channel_vars s_vars;
FILE_VERSION file_vers;
public int fetch_n;
public s_line_header_t * n_addr; /* malloc'd address of n data */
public UInt32 n_lines;
c_file_header_t hdr;
}
I added the structlayout line in the c# world.
Mine still doesn't compile.
I'm new to this so I don't know what is meant by wrapping unsafe code in c++ yet.
thanks so much,
saroj
|
|
|
|
|
Wrapping native objects means, you create a managed class in C++/CLI and hide your hdf_call_vars_t struct inside this managed class. Your library will only deal with this managed object and at the C# side you only have to deal with this managed object. This approach hides all the complexities of using native structs and simplifies your library's interface.
Here is working example of wrapping native object in a managed object.
using namespace System;
namespace Example {
struct hdf_call_vars_t {
int foo;
};
public ref class HdfCallVars
{
private:
hdf_call_vars_t* native;
public:
HdfCallVars()
{
native = new hdf_call_vars_t;
}
property int Foo
{
int get()
{
return native->foo;
}
void set(int value)
{
native->foo = value;
}
}
};
public ref class YourLibrary {
public:
int ReadFile(String^ file_path, HdfCallVars^ ret_vals)
{
return ret_vals->Foo;
}
};
} To use this library from a C# application,
using System;
using Example;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
HdfCallVars vars = new HdfCallVars();
vars.Foo = 10;
YourLibrary library = new YourLibrary();
int status = library.ReadFile("filepath", vars);
Console.WriteLine(status);
Console.Read();
}
}
}
Hope that helps.
Best wishes,
Navaneeth
|
|
|
|
|
Thank you so very much for taking the time to answer in such detail, Navaneeth! I learned a lot from your code. I do have a question though. Since my hdf_call_vars_t is a complex structure containing members whiuch are instances of other structs, how do I treat those? For example, it has a member 'struct channel_vars p_data.' A channel_vars type struct instance contains in it ints, doubles, enums and a void * . I'll of course create get set accessors for Channel_vars as you have shown for the int foo in your example.But do I need to make Channel Vars a wrapper class also?
thank you,
saroj
|
|
|
|
|
bonosa wrote: But do I need to make Channel Vars a wrapper class also? If that is something which user has to create, you need to make it a managed class. All your internal structures don't need to be wrapped because you handle the creation of those inside your main managed object.
Best wishes,
Navaneeth
|
|
|
|
|
Thanks Navaneeth, that almost compiled!
Now I have a problem!
int atClass1::read_file
(String^ file_path,
HdfCallVars % ret_vals)
I did the above as you advised.
However ret_vals has to be fed to an HDF5 function which needs a void* as one of it's arguments.
So I am stuck at the following line of code not knowing what to do:
io_err = H5Literate (group_id, H5_INDEX_NAME, H5_ITER_NATIVE,
&i, get_data, (void*)&ret_vals);
the compiler doesn't like (void*)&ret_vals....
What to do?
thanks,
saroj
|
|
|
|
|
bonosa wrote:
the compiler doesn't like (void*)&ret_vals.... Add a method to HdfCallVars so that it can give you the underlying native struct.
Best wishes,
Navaneeth
|
|
|
|
|
I wrote a blog post which covers the topic in detail. Take a look at this[^].
Best wishes,
Navaneeth
|
|
|
|
|
Navaneeth, your Main is written in C++ right? My main is in C#
thanks!
|
|
|
|
|
I've had a personal project in mind lately. Part of it will include user-created fields/field types. Think of it as an inventory control system. Each object will have common properties but I want the user to be allowed to create so many custom fields for each item type. As far as storing the custom fields, I know how I will achieve that aspect of it.
What I would like to know is how I should go about generating a dynamic view for those custom fields. I considered a "table" (DataGridView) at first. But I decided I would like to go with something more user friendly. It doesn't necessarily need to be a user-defined layout. But how can I present it in such a way that it's a Label control and then a TextBox control? My thought on it so far is to possibly use a TableLayoutPanel and add the controls for each custom field as necessary. Would this be an efficient solution or is there a cleaner solution?
If something like a TableLayoutPanel is the right tool for this, that's fine. I don't mind going that route. I just wanted to get some feedback from others before I continue.
I'm using VS2010 and C# 4.0.
Thanks a bunch!
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
|
Thank you, Orjan, for the suggestion. I hadn't thought about the PropertyGrid control. I'll look at the links more in depth here in a little bit. Currently I'm at work and have some things to get done throughout the day. But thanks for the info, I'll keep that in mind.
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
For a simple report runner I wrote a few years back I cobbled up a Form with Labels, TextBoxes, DateTimePickers, etc. on the fly based on the parameters of the report (Crystal or my own).
|
|
|
|