winforms - How to change direction in which a control resizes in vb.net -


i'm making application in vb.net , have control (a label specific) , it's been set auto size based on texts in it. currently, label box resizes left , down:

[label] ->
|
v

i want label resize right , down:

<-[label]
|
v

how this?

edit: label display's windows account name. it's aligned right side of window, that's why text must autosized , expand left rather right.

the way can think of adjust location according change in size. here's code that. used tag property hold current size before resize. in resize event handler adjusted location. whenever label's text changed tag gets size. when resize called size has changed , comparing 2 tell how change location. since defaul autosize operation down didn't change that.

private sub label1_textchanged(sender system.object, e system.eventargs) handles label1.textchanged     label1.tag = label1.size end sub  private sub label1_resize(sender system.object, e system.eventargs) handles label1.resize     dim tempsize new size(new point(0))     if label1.tag nothing label1.tag = label1.size     tempsize = directcast(label1.tag, size)     label1.location = new point(label1.location.x - (label1.size.width - tempsize.width), label1.location.y) end sub 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -