![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hi Boris, Based on my understanding, you'd like to validate the value of some custom properties of your custom control before build starts. If I'm off base, please feel free to let me know. In fact, you needn't trap the build start event from designer to get what you want. Instead, you could put the validating code in the set accessor of the custom property. The following is a sample: public ref class MyControl: public System::Windows::Forms::UserControl { private: System::String^ s; public : property System::String^ S { System::String ^ get() { return s; } void set(System::String ^ value) { if(value=="123") { throw gcnew Exception("invalid data"); } s = value; } } } Build the project and add the custom control on your form. If you set the value of the property S in the Properties window to "123", a dialog pops up saying "Property value is not valid" and forces you to change the value. Hope this helps. If you have any question, please feel free to let me know. Sincerely, Linda Liu Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Hi Boris, Thank you for your prompt reply! Generally speaking, if we make some changes in design time and then build the project directly, VS IDE saves the changes first which serializes the changes to code and then begin the compilation. Could you provide more information about your custom control and custom serializer? If it is difficult to describe, you may send me a simple project that could just reproduce the problem. To get my actual email address, remove 'online' from my displayed email address. Sincerely, Linda Liu Microsoft Online Community Support |
#6
| |||
| |||
|
|
Hi Linda, In my app, custom control is a grid. If I set value in grid cell using properties, yes, IDE saves changes before compilation. It looks more convenient for users to type values in grid cells directly, and update properties when cell value is stored (serializer is called in my code). The problem is that cell's new value is not stored with each character typed, but only when moving to another cell. If user types new value and forget to move to another cell before pressing F5, new value is not stored before compilation. From this point, it would be convenient to trap build start event and store the last cell value before compilation. If you'll not be able to help me trap this event, I'll try to find a workaround in control itself changing value store code. I see that using MenuCommandService class we can handle some menu commands in Designer. Is it possible to solve my problem with this or with something similar? Commands that I need are not in StandardCommands so it seems I just need a GUID and command ID for "Build" menu item to use MenuCommandService ? If this should work, where can I find GUID and command ID for menu items I'm interested in? Regards, Boris "Linda Liu [MSFT]" wrote: Hi Boris, Thank you for your prompt reply! Generally speaking, if we make some changes in design time and then build the project directly, VS IDE saves the changes first which serializes the changes to code and then begin the compilation. Could you provide more information about your custom control and custom serializer? If it is difficult to describe, you may send me a simple project that could just reproduce the problem. To get my actual email address, remove 'online' from my displayed email address. Sincerely, Linda Liu Microsoft Online Community Support |
#7
| |||
| |||
|
|
If you are using a DataGridView, you can force changes to be committed immediately instead of when leaving the field. Maybe that would help. Protected Overrides Sub onCurrentCellDirtyStateChanged(ByVal e As System.EventArgs) MyBase.OnCurrentCellDirtyStateChanged(e) If IsCurrentCellDirty Then CommitEdit(DataGridViewDataErrorContexts.Commit) End If End Sub On Wed, 26 Sep 2007 14:12:02 -0700, bmelt bmelt12345 (AT) community (DOT) nospam> wrote: Hi Linda, In my app, custom control is a grid. If I set value in grid cell using properties, yes, IDE saves changes before compilation. It looks more convenient for users to type values in grid cells directly, and update properties when cell value is stored (serializer is called in my code). The problem is that cell's new value is not stored with each character typed, but only when moving to another cell. If user types new value and forget to move to another cell before pressing F5, new value is not stored before compilation. From this point, it would be convenient to trap build start event and store the last cell value before compilation. If you'll not be able to help me trap this event, I'll try to find a workaround in control itself changing value store code. I see that using MenuCommandService class we can handle some menu commands in Designer. Is it possible to solve my problem with this or with something similar? Commands that I need are not in StandardCommands so it seems I just need a GUID and command ID for "Build" menu item to use MenuCommandService ? If this should work, where can I find GUID and command ID for menu items I'm interested in? Regards, Boris "Linda Liu [MSFT]" wrote: Hi Boris, Thank you for your prompt reply! Generally speaking, if we make some changes in design time and then build the project directly, VS IDE saves the changes first which serializes the changes to code and then begin the compilation. Could you provide more information about your custom control and custom serializer? If it is difficult to describe, you may send me a simple project that could just reproduce the problem. To get my actual email address, remove 'online' from my displayed email address. Sincerely, Linda Liu Microsoft Online Community Support |
#8
| |||
| |||
|
|
The problem is that cell's new value is not stored with each character typed, but |
#9
| |||
| |||
|
|
Hi Boris, Thank you for your reply! The MenuCommandService class implements the IMenuCommandService interface, which is the managed interface used to add handlers for menu commands and to define verbs. However, the Build/Start Debugging commands are not commands on a designer, instead, they're commands of Visual Studio IDE. So it's impossible to trap a build start event from designer. The problem is that cell's new value is not stored with each character typed, but only when moving to another cell. When we make any change on a control in the designer, the changes should be serialized into the InitializeComponent method immediately, even if we don't save the changes. I suggest you to type new value in a grid cell and switch to the code view to see if the changes are serialized into the form's InitializeComponent method. If you could create a simple project that could reproduce the problem, I still recommend you to send the sample project to me. Then I may give you a direct assistance. I look forward to your reply. Sincerely, Linda Liu Microsoft Online Community Support |
#10
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |