Change the anchor property of a control.

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 :) 

0
Mr
6/12/2010 9:46:37 PM
dotnet.languages.vb 830 articles. 0 followers. Follow

7 Replies
1324 Views

Similar Articles

[PageSpeed] 55

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
0
Armin
6/12/2010 10:17:07 PM
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/>
0
Herfried
6/12/2010 11:54:19 PM
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 :) 

0
Mr
6/13/2010 5:58:09 AM
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 :) 

0
Mr
6/13/2010 6:26:44 AM
Why then do you set that anchor.
You can remove it completely in my idea.

In my idea is for your solution panels and docking more used.


"Mr. X." <nospam@nospam_please.com> wrote in message 
news:OSB4qFsCLHA.5464@TK2MSFTNGP05.phx.gbl...
> 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 :)
> 
0
Cor
6/13/2010 6:46:54 AM
"Cor Ligthert[MVP]" <Notmyfirstname@planet.nl> wrote :
> Why then do you set that anchor.
> You can remove it completely in my idea.
>
> In my idea is for your solution panels and docking more used.
I am using the PropertyGrid panel, and it has anchor on it - can I hide it ?
Besides, I have overcomed the anchor problem.
I need the propertyGrid for the most of the propeties (colors, borders, etc 
....).
All the layout, and position - I am doing by hands in the hard way.

Now - I try to overcome setting parent-child relations as it should be set 
(panel that has some controls on it).

Thanks :) 

0
Mr
6/14/2010 8:23:34 AM
On Jun 13, 12:46 am, "Mr. X." <nospam@nospam_please.com> wrote:
> Hello.
> How can I capture the event, when changing the anchor property of the
> control ?
>
> I.e :
> myPanel.anchor =3D AnchorStyles.Left & AnchorStyles.Bottom
> ...
> How can I know, when the Anchor property is changed (which event?) ?
>
> Thanks :)

Hi,

Though there's no built-in event like OnAnchorChanged, however you can
still write your own event and sync it with the original anchor
property behind the scenes. The key part is that you have to assign
anchor property to your own property like named "PropGrid1Anchor",
rather than native Control.Anchor at runtime, like in the example
below.

Place this into your existing Form class code:

'--------------------------------------------------------------------
Private Sub Button1_Click _
    (ByVal sender As System.Object, _
     ByVal e As System.EventArgs) Handles Button1.Click

' Change our custom anchor property to see it raised
Me.PropGrid1Anchor =3D AnchorStyles.Right _
Or AnchorStyles.Bottom

    End Sub

Public Event PropGrid1AnchorChanged(ByVal sender As Object)

Public Property PropGrid1Anchor() As AnchorStyles
Get
            Return Me.PropertyGrid1.Anchor
        End Get
        Set(ByVal value As AnchorStyles)
            ' It will also set built-in anchor property
            Me.PropertyGrid1.Anchor =3D value

            ' Let it raise
            RaiseEvent PropGrid1AnchorChanged(Me)

        End Set
    End Property

    Public Sub PropGrid_AnchorChanged _
    (ByVal sender As Object) _
    Handles Me.PropGrid1AnchorChanged
        ' Test it
        MsgBox("Raised!")
    End Sub

'--------------------------------------------------------------------
Note that you're assigning anchor property to specific instance of
PropertyGrid control, that is PropertyGrid1. You can customize it in
order to your needs. There may be other thoughts, but also it can be
an option to evaluate.

HTH,

Onur G=FCzel
0
ISO
6/14/2010 1:32:09 PM
Reply:

Similar Artilces:

Change of recipient/sender display name
Hi All, Environment :- Windows 2003 x64 with exchange 2007 (All in one role) Outlook client :- 2003, 2007 We have created a list of mail contacts (which under GAL) in exchange 2007, these mail contacts are associates with external email address, each of contact has a naming standard for display name, for example, display name is HD Finance Manager, external email address is fin_manager@hdemea.com I want to configure outlook client to show the display name according to mail contacts whenever the email address is match to mail contacts list (GAL), for example, an email sent from the email a...

Change default font format in Excel
I have an existing workbook with cell text entries in regular black font. I want to make a number of additional entries in various cells in this workbook, and I want all my text entries to be a different font format (bold, red). Is there a way to do this automatically without highlighting each entry I make and manually changing the cell format? Thanks. Michael, Copy the code below, right-click on your sheet tab, select "View Code" and paste the code in the window that appears. HTH, Bernie MS Excel MVP Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Cou...

Change <value> in outlook
We Have Exchange 2003 sp2 and outlook 2003 sp2. I have renamed 2 AD accounts. Changed all display names, accounts name etc with the 2 accounts. When users open outlook and send to renamed account they see account name <oldaccountname> in the autocomplete list. I have cleared nk2 files in profile , but it still shows newaccount <oldaccountname> in drop down box. Is there a way to edit the <oldaccountnam> value of the renamed account? I tried the same thing with a freshly loaded PC. with the same result. Thanks You can delete the nickname files. -- Ed Crowley MVP - E...

changing the cell information #2
Hi I have files I tried to change the cell information to another cel that have to be the blank for a row that contains director name in cel A and for the movie titles I have to have director names instead of th title names.Please help me, the data in cell B sholuld have to be, A 1 D:B.Jane 2 T:Back to the future 3 T:Aliens 4 T:X-files 5 D:Adam Mathew 6 T:Core 7 T:Titanic B 1 (empty) 2 D:B.Jane 3 D:B.Jane 4 D:B.Jane 5 (empty) 6 D:Adam Mathew 7 D:Adam Mathew thanks -- Message posted from http://www.ExcelForum.com ...

Change links to hyperlinks in a workbook?
I have 5 Income Statement sheets in a workbook. The first sheet is an Income Statement summing four departments (listed by columns). Column B has Dept 1 data, column C has Dept 2 data, etc. ALL data on this sheet is linked (referenced) to the other four sheets which are the individual departments. I know I can set hyperlinks one at a time, but is there a way for me to have each of those links (every cell containing the data from the other four sheets) become hyperlinks? If I have to add another sheet that mirrors the summary sheet but has hyperlinks, that would be fine. I am just ...

building form @ runtime vs. hiding existing controls
I'm trying to decide just how bad runtime design is. Most opinions seem to steer clear of adding controls, events, etc at runtime. Instead, y'all advocate keeping controls on the form and hiding them as necessary. In my application (which will not be an MDE) , each user session builds a new form - from scratch. Once the form is built, there are no design changes. And when the user is done the form object is deleted. Troubleshooting may be more difficult with a form that only exists at runtime. OTOH, documenting and tracking unused controls (or not having enough controls, ...

Changing Interface OWA (exchange 2003)
Not sure if you all remember but back in the Exchange 5.5 days we use to be able to go onto a site and put in the username of the person mailbox you want to access, then a windows pop up would come up asking you for your credentials. I was wondering if that is still possible to do that in Exchange 2003? If so how can that be done? Configure Forms-Based Authentication (FBA). -- Ed Crowley MVP - Exchange "Protecting the world from PSTs and brick backups!" "John" <nospam@comcast.net> wrote in message news:evIllMndHHA.596@TK2MSFTNGP06.phx.gbl... > Not sure...

Exchange 2003 on a Domain Controller.
Hi All, I have a WinNT/Ex5.5 to AD 2000/03 and Ex2k3 migration to do. The client is a small company with only about 15 users. The are a network solutions company that needs flexibility so SBS is out of the question. My initial thought was to have 2 Win2k domain controllers/file servers and one Win2k3 member server running Ex2k3. They only have 2 Win2k server licenses and 1 Win2k3 server license. The problem is that they want to be able to use RPC over HTTPs. I understand that requires a 2003 Global Catalogue server. So, my plan of the 2000 DCs doesn't work. My question is:...

Document Properties in header / footer without VBA
Hello, I was looking for way to insert document properties, also maybe custom doc properties into the header or footer of Excel WITHOUT the usage of vba macros. e.g. something like if you would like to insert the date &[date] I would like to use &[Author] but excel doesnt accept stuff like this. is there a way?! somehow. thanks a lot hans Hi not possible without VBA. So no way to do this witout macros -- Regards Frank Kabel Frankfurt, Germany hans werner wrote: > Hello, > > I was looking for way to insert document properties, also maybe custom > doc properties into ...

Change License / Company name
Hi, we tried CRM 1.2 with the MSDN license key. Now my company bought a 25 user Proffesional Suite license and I want to change the key on the production server. Is there an easy way to do this?? The only solution I see, is via the Data Migration Framework. Erik. How about the re-deploy tool? "Erik" <none> wrote in message news:u0SXdbXlEHA.3452@TK2MSFTNGP15.phx.gbl... > Hi, > we tried CRM 1.2 with the MSDN license key. Now my company bought a 25 > user > Proffesional Suite license and I want to change the key on the production > server. Is there an easy wa...

Locking cell color while allowing data changes in cell
In excel 2000, I created an attendance worksheet for my classes.(Alphabetized names down left vertical column. Dates across top of horizontal row.) I added a different color to all cells in every other row to make for easier reading of each student's name and absences. Every other row stays with a white background. My question: I wondered if it was possible to lock row colors while allowing data to change on top of them. If a new student is added to my class in alphabetical order, the alternating color pattern is often lost. It is a pain to rechange row and cell colors. Any shortcut ...

Changing the Selection Fields in a Combo Box
Hi, I've created a Combo Box using the Controls Wizard. In creating the control, I specified that my unique value to be stored in the table is an ID. When the user views the selection options in the Combo Box, I'd like to have the ID field hidden and only see the text values, while still storing the ID in the appropriate column. This is probably a second question. Also, when the user views a form that has been populated, I'd like them to see the actual textual values on the form, as just the stored ID value. Is that possible to do with the one Combo Box or is that...

APAY Frequency changes mysteriously
Has anyone noticed that if, for example, you set up an APAY bill monthly, that all of a sudden the next pay date is many months later? It will be cruising along fine, sending bills monthly via MSN Billpay automatically and then one day I go to look at BILLS AND DEPOSITS and some of the autopay's that should be due next month say something crazy like it wont be paid until three months from now or even Jan of next year. I have to cancel the autopay and resubmit it with the proper information. This has happened to me several times in Money2003 on XP... p.s. I tried out the archive feature t...

Background changes conditionally
Hi all, I have a spreadsheet that shows the floor plan layout of my call centre. On each desk, the desk number and identity are displayed. I would like to colour the background for those pcs that are on the same subnet. I have a sheet called data - it contains Table Number, Desk Number, PC ID, IP Address. How could I get it to change the background colour if the pc is on subnet 162, and set a different colour for those on subnet 167 any ideas? -- PeterG ------------------------------------------------------------------------ PeterG's Profile: http://www.excelforum.com/member.p...

gp10 change clients pointing to different server
In version GP 10 I have clients pointed to a test server. When production server is ready what do i do to point the clients to the production server e.g. GPServer. Would I change the odbc connection? Or Rerun the client installs? Any help is appriciated. Thank YOu As long as your production server has THE SAME level service pack as your clients and THE SAME third party products all you need to do is repoint your ODBC to the production server. Best regards, -- MG.- Mariano Gomez, MIS, MCP, PMP Maximum Global Business, LLC http://www.maximumglobalbusiness.com "2020" wro...

OWA & "User must change password at next logon"
Current Environment: Running EX2K3(SP2), and using OWA as the ONLY option to get e-mail; using certificates (https:\\owa.domain.com\exchange) & forms based Authentication. Problem: I create a NEW user in AD; e-mail enable it, and select "User must change password at next logon". Now when the user tries to log in (VIA OWA) s/he is not prompted to change the password / it won't even log them in. It use to work with our old exchange 2000 environment, where it gave them the opportunity to change the password at sign on. Answer: ? There is one property in MetaBase: ...

List control selction and deselection
For selecting an item from a CListCtrl just call mList.SetItemState(iItem,LVIS_SELECTED | LVIS_FOCUSED, 0xFF) during Initialization For deslecting we need to insert item once again, ie mList.DeleteAllItems() mList.InsertItem() i know this is not a good method, but i didnt get any other options. if anyone know, pls let me know!!! Regards "johnWins" <johnsvakel@gmail.com> wrote in message news:2ccf2c5c-eb5c-46fd-9bd5-30d89d2048f6@v67g2000hse.googlegroups.com... > For selecting an item from a CListCtrl just call > > mList.SetItemState(iItem,LVIS_SELECTED | LV...

Changing default Print copies
Hi, I have a workbook that has a worksheet with default printing copies of 3. Even when I go to page setup and change the number of copies to print to 1 it will automatically revert to 3 the next time I bring up the print dialog. I have also looked through the VBA editor at the worksheet for any oddities and have found none. Does anyone know how to change this permanently? Thanks in advance. Pach >Even when I go to page setup and change the number of copies to > print to 1 it will automatically revert to 3 the next time I bring up > the print dialog. Look at the defaults for you...

HOW DO I COPY FORMULA WITHOUT CHANGING CELL REFERENCE
My cell c1 contains the formula b1-a1.when i copy this formula to cells d1 and e1 the cells d1 and e1 have the following formula : d1=c1-b1 e1=d1-c1 but i want the following d1 should be b2-a2 and e2 should be b3-a3 how do i do this? One way... In C1 enter & copy across: =INDEX($A:$A,COLUMN()-COLUMN($C$1)+1)-INDEX($B:$B,COLUMN()-COLUMN($C$1)+1) anantth wrote: > My cell c1 contains the formula b1-a1.when i copy this formula to cells d1 > and e1 the cells d1 and e1 have the following formula : > d1=c1-b1 > e1=d1-c1 > > but i want the following > d1 should be b2-...

stop automatically changing formula!
i have a countif function COUNTIF(Locking!I16:I40,"f") when i copy this and paste it to the next cell, the formula automatically change to COUNTIF(Locking!J16:J40,"f") How do I stop it from changing column I to J?!?!?! thanks. Caryn, =COUNTIF(Locking!$I$16:$I$40,"f") or =COUNTIF(Locking!$I16:$I40,"f") HTH, Bernie MS Excel MVP "caryn" <caryn.tan@gmail.com> wrote in message news:d7n4u3$hgi$1@avnika.corp.mot.com... > i have a countif function > COUNTIF(Locking!I16:I40,"f") > when i copy this and paste it to the nex...

unable to change password via OWA
Hi, I am having a problem with users changing passwords via OWA. When they click on the change password button, it comes up with change password screen and asked for domain name, user name , old password ,etc. The problem that I have is that when I submit it, it comes up with message saying "Either the password is too short or password uniqueness restrictions have not been met." But I didn't define any password policy on DC. What can I do ? Kindly please give me some idea. Thanks Losa If you are running windows and exchange 2003 then there are password requirements that...

prompting to save workbook every time (even when no changes made)
i have 3 workbooks all very similar and every single time i open any o them, even when not changing anything, i am prompted to save th thing. its so bad that i can literally open the workbook then click the clos button straight away and it STILL prompts me to save it because i seems to think something has changed. as far as i can see i dont have any macros or anything that will ru every time it starts and change something (i did have a = today in on cell which kept the date as today but taking this out made n difference -- Message posted from http://www.ExcelForum.com Hi Neowok! You prob...

find match then change cell value
In column A I have cells filled with text and in column B I have cells filled with numbers. I need to check if the number in cell C1 equals any of the numbers in column B. If a match is found then I need to change the text in column A to CBO. e.g. Column A Column B Column C aep 5 7 apa 0 gci 59 xto 5000 xle 7 oih 253 ed 8 Since the cell C1 = 7 equals the 7 from column B, I need to change the data in column A from xle to cbo. Is this possible...

Insert new row as cell contents change
Insert new row as cell contents change. After importing data I have a spread sheet with a column that contains a series of alpha numeric characters. At various random intervals in this column the contents change. EG rows 1 to 4 could contain ABC, then rows 5 to 15 could become 222. I am looking for a method to insert a blank row automatically between the rows were the contents change. Many Thanks Geo George If you are familiar with VBA the code below will do what you want. Preselect the column of data first Sub InsertRowAfterValueChange() Dim myCell As Range Dim sCurrVal As String ...

custom controls
Last time I checked VS 2002, MFC didn't support as many custom controls as you could use with .NET. (Not sure of VS2005 added more support.) I was wondering if there was a site that sold unmanaged MFC controls. I know you can find some for free on codeguru and such, and I have been looking there too, but I am also looking to see what else is avaliable that might save me some time. Thanks. Depends on what kind of control you want? Try http://www.codejock.com http://www.roguewave.com/products/stingray/ AliR. "quat" <spam@void.com> wrote in message news:pVDUf.94...