Prev: Uninstall
Next: Using LINQ to SQL
From: Mr. X. on 12 Jun 2010 17:46 Hello. How can I capture the event, when changing the anchor property of the control ? I.e : myPanel.anchor = AnchorStyles.Left & AnchorStyles.Bottom .... How can I know, when the Anchor property is changed (which event?) ? Thanks :)
From: Armin Zingler on 12 Jun 2010 18:17 Am 12.06.2010 23:46, schrieb Mr. X.: > Hello. > How can I capture the event, when changing the anchor property of the > control ? > > I.e : > myPanel.anchor = AnchorStyles.Left & AnchorStyles.Bottom > .... > How can I know, when the Anchor property is changed (which event?) ? Like I said, about once or twice, you should switch Option Strict On. Then, why do you want to have an event? There is no such event, and there is no overridable method that is called when the property changes (like 'OnAnchorChanged'). I would handle the Resize event instead. Whether the control is anchored or not shouldn't matter. If you set the property like above, you know where the value changes. -- Armin
From: Herfried K. Wagner [MVP] on 12 Jun 2010 19:54 Am 12.06.2010 23:46, schrieb Mr. X.: > How can I capture the event, when changing the anchor property of the > control ? There is no specific event, but you may want to take a look at the control's 'Layout' event and 'OnLayout' method. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
From: Mr. X. on 13 Jun 2010 01:58 A little problem, and I shall explain the meaning of my program : ---------------------------------------------------------------------------------- I am creating a min-ide screen (I can drag and drop on it some components, with no events on them : only design). 1. I don't want that the components will act as a real component (there should not be event on it, when pressing mouse-click, for example). (disable the events, when clicking - If I knew that, it would solve many problems). 2. I want to capture some layout events. It may be a bad solution, but far as I have found yet is : 1. I have created an ide with handles, so I can drag and drop component, move them, stretch them, etc. For that I made two controls : First one is the "visual control" (that has no parent control, but "knows" how to draw the control (but is not paintable on screen). Second one is an "active control", which is a pictureBox, that is paintable. When changing some properties on the first one, such as color, text, etc. I move the "image" from the first one to second control, by DrawToBitmap method. 2. For some layout (only layout), because the first control is invisible one, I capture its event (such as DockChanged, resizing and moving), and checking the delta of width, height, etc. (For DockChanged - when this occurred on first control, I do the same for the second one, and do some changes on width, height, top, left, by checking the deltas). 3. Also, I am using propertyGrid control, that is connected to the first control (named "active control"). 4. Everything works fine, and good, but the only thing that I cannot handle when anchor is changed. Solution for that, I think : 4.1. Giving up the anchor property and hide it on property grid (how doing that ?). 4.2. Changing the first control behavior, that it should act as a control for design time only. Summary (Major questions) : ================== 1. Need an elegant solution, and knowing whether my solution is bad or good. 2. How can I "disable" the events on the control (and alow only some events), so the events won't occur when running my code (such as button click. There are 10 different components I can drop on screen) ? 3. How can I give up and hide some properties on the propertyGrid control? Thanks :)
From: Mr. X. on 13 Jun 2010 02:26
O.K. Solved !!! I have solved the above, by keeping the old anchor, and every time when the event : properyGrid.SelectedGridItemChanged, I am checking whether the old anchor has changed. If it is changed, then I move the same anchor from the first control to the second one. That's solved the problem, and I can keep on ... If you have any other comments on my approach, I would like to know about. Thanks, anyway :) |