How do I center a textbox inside a panel in visual studio? -


when set textbox's anchor top,bottom,left,right textbox still stays on top. don't understand, seems work labels , buttons. kinda need anchor property adapt form resize.

i'm sorry if i'm missing incredibly obvious.

if understand question, want single line textbox appear centered vertically , horizontally in form. still without showing more 1 line. in case set anchor left , right property have textbox centered horizontally on form, vertical position need work code adjusting iop property of textbox in resize event of form

for example, after call initializecompoment of form add following code center textbox (c# convertible vb.net)

textbox1.left = 10; textbox1.width = yourform.clientsize.width - 20; textbox1.top = (yourform.clientsize.height / 2) - yourform.height / 2; textbox1.anchor = anchorstyles.left | anchorstyles.right; 

and add event handler resize event of form call again vertical repositioning of textbox

protected void yourform_resize(object sender, eventargs e) {     textbox1.top = (this.clientsize.height / 2) - textbox1.height / 2; } 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -