Problem setting width in dynamically created textbox in vb.net - html

I use these lines to dynamically create buttons and text boxes.
For i As Integer = 1 To 100
Dim newButton = New Button()
newButton.Text = i
newButton.ID = i
newButton.CommandName = i
newButton.Style.Add("width", "20%")
newButton.Style.Add("height", "100%")
Panel1.Controls.Add(newButton)
Next
For i As Integer = 1 To 100
Dim newtext = New TextBox()
newtext.TextMode = TextBoxMode.MultiLine
newtext.Style.Add("width", "20%")
newtext.Style.Add("height", "100%")
Panel2.Controls.Add(newtext)
Next
While the buttons fit the page width correctly, text boxes leave a space to the right.
1 2
I've tried assigning a class instead of width, but it doesn't work.
"min-width" also doesn't work.
How to set the text boxes to fit the page width?

I resolved setting textbox border-width and padding to zero pixels.
newtext.Style.Add("border-width", "0px")
newtext.Style.Add("padding", "0px")

Related

Adjusting line in Access VB

I've seen a number of question/answers on how to adjust the height of lines when the detail section expands; however, haven't seen anything about line width.
I got the line to adjust height by using:
Dim CtlDetail As Control
Dim intLineMargin As Integer
intLineMargin = 0
For Each CtlDetail In Me.Section(acDetail).Controls
With CtlDetail
If CtlDetail.Name = "Line192" Or CtlDetail.Name = "Line193" Then
Me.Line ((.Left + .Width + intLineMargin), 0)-(.Left + .Width + intLineMargin, Me.Height)
End If
End With
Next
Set CtlDetail = Nothing
End Sub
BUT, while the line does adjust height the width reverts back to "hairline" rather than the points I prefer.
Thanks for any help I appreciate it.

as3 textfield wordwrap true causing textwidth to be weird

I'm trying to wordwrap a textfield inside a button, however after i set wordwrap to true some unexpected behavior happened.
Button.width = 390;
Button.textField.autoSize = TextFieldAutoSize.LEFT;
Button.textField.border = true;
Button.textField.wordwrap = true;
Button.textField.multiline = true;
Button.textField.width = textButton.width - 10;
Button.textField.x = 5;
Button.height = 60;
This is what happens:
When I'm outputting the Button.textField.textWidth, it seems shown a value that so much less than Button or Button.textField.width. I just want to make the word break after textwidth meets the textField.width maximum value. Is there anything that I can do to change this behavior? …since I can't change the value of Button.textField.textWidth (read-only).
Comment out the Button.textField.autoSize setting. This is probably what is throwing everything off.
You're setting the text field's width to match the size of the button when you set width = textButton.width - 10, but you're also telling it to automatically resize the textField to match the size of the actual text when you set the autoSize setting. So it's not going to fit the button the way you want it to.

Set the content of PDF to center

I am generating dynamic multicell with string. Like A, B, C etc. I want to center those multicell on the page. I need to make the $pdf->SetMargins() dynamic, which means it will automatically center itself when the content is loaded. This is a code I tried but something is wrong.
$pdfWidth = 210;
col = 9; // This is dynamic so it can be any value from 5-20;
$mar = (($pdfWidth + ($col * 8)) /2)/2;
$pdf->SetMargins($mar,0,0);
I'm not sure why you're dividing by 2 twice. If you take the total width of the page, minus the content and divide that by two you have your desired margin already. Also, don't forget to set the override parameter in SetMargins() to 'true'.
$pdfWidth = 210;
$col = 9;
$mar = (($pdfWidth - ($col*8)) /2); //Only one division by 2 is required
$pdf->SetMargins($mar,0,0, true); //the 'true' is necessary or it won't override the default margins
//VERY IMPORTANT that you set all the above BEFORE adding the page!
$pdf->AddPage();
//Content of page
Now any MultiCell with cell width of 8, as you provided in the example, should be perfectly centered on the page.

How to get a RadioButton's label height - AS3

I want to get radioButton's label height in as3.
I have 5 radio buttons in my radioButton group. One of those radioButtons has a three line label, another has a single line etc...
When I try to access the radioButton.height, I always get same value regardless of the label height.
I need to know the height of the label, so I can set the radioButton y coordinate accordingly.
can I change the radioButton's label height?
spacing = 30;
rb.label = tempQQString //from xml. long or short string anyone
rb.group = myGroup;
rb.value = i + 1;
rb.x = answerX;
rb.y = questionField.height + (questionY+20) + (i * spacing); // here use rb.height or rb.textField.height
trace("rb height**" + rb.height) // always get velue 22;
addChild(rb);
RadioButton and any fl control that extends labelButton (all the ones that have a label), expose the actual text field with the .textField property.
So for your example, instead of using rb.height, you would use rb.textField.height to get the height of just the label portion of the control.
You can also set properties on the textField as well.
rb.textField.background = true;
rb.textField.backgroundColor = 0xDDDDDD;
rb.textField.multiline = true;
rb.textField.wordWrap = true;
rb.textField.autoSize = TextFieldAutoSize.LEFT;
now, for your scenario, you may be better off just using the radio button's bounds instead, as it will be the REAL height of the object.
rb.getBounds(rb).height; //this will be the true height of the component.
If your label was one line and your icon was taller than your label, you could potentially be getting a value from rb.textField.height that is smaller than the real height of the radio button.
Try this.
for(var i=0;i<rb.numChildren;i++){
if(rb.getChildAt(i) is TextField){
var txt:TextField = rb.getChildAt(i) as TextField;
trace(txt.height+":"+rb.height);//traces the height of text field and radio button
}
}

Is there a way to get graphic text to scale in ArcMap?

I'm using this code to create text in ArcMap. But I can't seem to get it to scale like annotation text when you zoom in.
Does anyone know how to do this?
//'First setup a color. We'll use RGB red
IRgbColor pRGBcolor = new RgbColor();
pRGBcolor.Blue = 0;
pRGBcolor.Red = 255;
pRGBcolor.Green = 0;
//'Next, cocreate a new TextElement
ITextElement pTextElement = new TextElementClass();
//'Query Interface (QI) to an IElement pointer and set
//'the geometry that was passed in
IElement pElement = pTextElement as IElement;
pElement.Geometry = Point;
//'Next, setup a font
stdole.IFontDisp pFontDisp = new stdole.StdFont() as stdole.IFontDisp;
pFontDisp.Name = "Arial";
pFontDisp.Bold = true;
//'Next, setup a TextSymbol that the TextElement will draw with
ITextSymbol pTextSymbol = new ESRI.ArcGIS.Display.TextSymbolClass();
pTextSymbol.Font = pFontDisp;
pTextSymbol.Color = pRGBcolor;
pTextSymbol.Size = Size;
pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
pTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
pTextSymbol.Angle = Angle;
pTextSymbol.Text = Text;
//'set the size of the text symbol here, rather than on the font
//'Next, Give the TextSymbol and text string to the TextElement
pTextElement.Symbol = pTextSymbol;
pTextElement.Text = pTextSymbol.Text;
pTextElement.ScaleText = true;
ESRI.ArcGIS.Carto.IElementProperties3 aoElementPro = pTextElement as ESRI.ArcGIS.Carto.IElementProperties3;
aoElementPro.ReferenceScale = cGISHelpers.MapDomain.Map.MapScale;
We can very well add text which changes it size according to the scale. for this, we need to use the IElementProperties3.ReferenceScale Property.
I do not have C# code, but am attaching some sample VBA code that you can modify.
'--------------------------------
Sub ChangeTextElemRefScale()
Dim pDoc As IMxDocument
Dim pContainer As IGraphicsContainer
Dim pElement As IElement
Dim pTextElement As ITextElement
Dim pActiveView As IActiveView
Set pDoc = ThisDocument
Set pActiveView = pDoc.ActiveView
Set pContainer = pActiveView
'Loop through the graphics container
pContainer.Reset
Set pElement = pContainer.Next
While not pElement Is Nothing
'Get the specific text element
If TypeOf pElement Is ITextElement Then
Set pTextElement = pElement
If pTextElement.Text = "oregon" Then 'change this to your text element's text
Dim pElemProp As IElementProperties3
Set pElemProp = pTextElement
pElemProp.ReferenceScale = 15000000
End If
End If
Set pElement = pContainer.Next
Wend
pDoc.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing
End Sub
'--------------------------------
To my knowledge, you can't get a TextSymbol to scale along with the map. That's because the TextElement isn't changeable based upon the map's extent but, instead, uses the font size to determine how large it's going to appear on the screen.
The best way that I can think of to do it while still using a TextSymbol is to change the point size (and, if the extent is large enough, hide/show the element) as the extent changes. I don't know of a "text control that pays attention to the extent," which is what you would really need.
Alternately, couldn't you just use an annotation layer or label the layer where you want the text size to change?
The ITextElement has got a property ITextElement.ScaleText. Set this to true and the text size will adapt automatically.