Windows Forms Controls in Excel

When you add controls to an Excel worksheet, they are added as floating controls. You can move a control to any area of your worksheet, including positioning it between columns or rows, as shown in Figure 8.19. These controls do not automatically resize when you resize a column or row. You can change this behavior by using the Format Control dialog box.

/ÉHcelWorkbookl.Hls* Start Page

~ X

: J tf U ^ (J A W * ÎJ Ä - ^ "> - C - S, >: - 5. m

ioo%

• « I-

Arial

- 10

- B I

u m

■ «mis % >

«-.I .00 .00 +.0

: —3» • J 1

B11

ft

A

B

c

D

E

F

G

H

1

J T"

1

Ipj

2

3

4

5

BuHOrtl

6

7

8

BuUortï

3

10

11

1

12

13

Figure 8.19. Placing controls on an Excel worksheet

Figure 8.19. Placing controls on an Excel worksheet

To make control resize with worksheet cells, you set the Move and Size with Cells option.

1. Right-click the control and click Format Control.

2. On the Properties tab, select the Move and Size with Cells option, as shown in Figure 8.20.

Now when you resize a column, the control also resizes. Figure 8.21 shows Button1, which has resized when column B was resized. Button2 has not resized, because by default it is set to Move but Don't Size with Cells.

Figure 8.20. Setting the object positioning properties of a control in Excel

-Il t|| B I u 1 ■= ■ =■ S 1 $ % t V - - - » - A - £ 1

_ActiveXWrap..

f* =EMBED("WmForms.Control.Host","")

A

B H

+ c

D

E

F

G

H

I

1

2

3

4

5

o Button! E

6

7

8

Bultan2 I

3

10

11

Figure 8.21. Resizing a column and controls in an Excel worksheet

Figure 8.21. Resizing a column and controls in an Excel worksheet

0 0

Post a comment