What must I set so that the label text will wordwrap respective to the parent panel's width? - tpanel

I'm using C++ Builder.
I have created a panel and set the width of said panel to 350.
I am using the following code to create labels.
TLabel* tempLabel = new TLabel(this);
tempLabel->Parent = Panel6;
tempLabel->Caption = temp->Text;
tempLabel->Top = 25*i;
tempLabel->Font->Style = TFontStyles() << fsBold;
tempLabel->Font->Color = clRed;
TLabel* tempLabel2 = new TLabel(this);
tempLabel2->Parent = Panel6;
tempLabel2->Caption = temp->Title;
tempLabel2->Top = tempLabel->Top + 10;
tempLabel2->AutoSize = true;
tempLabel2->WordWrap = true;
TLabel* tempLabel3 = new TLabel(this);
tempLabel3->Parent = Panel6;
tempLabel3->Caption = temp->Message;
tempLabel3->Top = tempLabel2->Top + 10;
tempLabel3->AutoSize = true;
tempLabel3->WordWrap = true;
The result is that the captions of tempLabel2 and tempLabel3 are extending passed the 350 width of the containing panel. I have read online about setting AutoSize to true and WordWrap to true. This attempt was not successful.
What must I set so that the label text will wordwrap respective to the parent panel's width?

Related

GridView - Editable ComboBox Data become slow

this is the code which i custom the column in gridview to show the data. i try to get the data from editable text that i type from comboBox, but the data output become too slow to appear in list
settings.Columns.Add(column =>
{
column.FieldName = "Food";
column.Caption = "Food List";
column.Width = 350;
column.ColumnType = MVCxGridViewColumnType.ComboBox;
var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
comboBoxProperties.Width = new System.Web.UI.WebControls.Unit(350);
comboBoxProperties.DataSource = Food.Shared.ListFood;
comboBoxProperties.TextField = "Value";
comboBoxProperties.ValueField = "Key";
comboBoxProperties.ValueType = typeof(Guid);
comboBoxProperties.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
comboBoxProperties.ItemStyle.Wrap = DefaultBoolean.True;
comboBoxProperties.ClientInstanceName = "foodListTo";
});

How to set the height of panel screen header in Feathers UI?

I created a PanelScreen from feathers.controls. However, I feel like I can only change the width of its header, How can I change the height of its header?
for example:
var layout:PanelScreen=new PanelScreen;
layout.title = 'mm';
this.addChild(layout);
layout.validate();
layout.width = 100; // it works
layout.height = 100; // it doesn't work
you need to change the panel's headerFactory like this
panel.headerFactory = function():Header
{
var header:Header = new Header();
header.height = 100;
return header;
};

HTML elements do not position as expected

I am dynamically assembling divs within divs and adding text to each internal div - building a list with a Javascript list adapter. The internal list divs display as desired, but the respective text divs in each list div does not:
Example:
As you can see in the image the text div on the right in red text is slightly higher than the one on the left in green. I have set the properties for each as such:
In Javascript I add them in a loop using the following:
var divGreen = document.createElement("div");
divGreen.style.position = "relative";
divGreen.style.width = "10%";
divGreen.style.left = "100%";
divGreen.style.top = "100%";
divGreen.style.marginLeft = "-40%";
divGreen.style.marginTop = "-20%";
divGreen.style.color = "green";
divGreen.style.textAlign="left";
divGreen.style.backgroundColor = "#cccccc";
divGreen.innerHTML = 'Text';
div.appendChild(divGreen);
var divRed = document.createElement("div");
divRed.style.position = "relative";
divRed.style.width = "10%";
divRed.style.left = "100%";
divRed.style.top = "100%";
divRed.style.marginLeft = "-20%";
divRed.style.marginTop = "-20%";
divRed.style.color = "red";
divRed.style.textAlign="left";
divRed.style.backgroundColor = "#cccccc";
divRed.innerHTML = 'Text';
div.appendChild(divRed);
Also, the literal Text is used to eliminate character size differences.
Why do they not line up vertically as expected? What am I missing?
After reviewing this SO post - It's clear my understanding of absolute positioning was wrong. By setting the position absolute on the parent, I can use absolute positioning of it's children relative to the parent. The key is the parent having position set to absolute!
var divGreen = document.createElement("div");
divGreen.style.position = "absolute";
divGreen.style.width = "10%";
divGreen.style.left = "100%";
divGreen.style.top = "37px";
divGreen.style.marginLeft = "-40%";
divGreen.style.color = "green";
divGreen.style.textAlign="left";
divGreen.style.backgroundColor = "#cccccc";
divGreen.innerHTML = 'Text';
div.appendChild(divGreen);
var divRed = document.createElement("div");
divRed.style.position = "absolute";
divRed.style.width = "10%";
divRed.style.left = "100%";
divGreen.style.top = "37px";
divRed.style.marginLeft = "-20%";
divRed.style.color = "red";
divRed.style.textAlign="left";
divRed.style.backgroundColor = "#cccccc";
divRed.innerHTML = 'Text';
div.appendChild(divRed);
Now my links are aligned vertically as intended:
I had this happen to me. I was able to put my code in a table.
<table>
<tr>
<td>
html code here
</td>
</tr>
</table>
TR means table row and td is table data

Is dynamic div loading taking more time than static div in HTML?

In my application, a large number of divs is dynamically rendered in an HTML page through the use of JavaScript. In fact, there are more than 100 dynamically created divs. Loading the content from server side, it is taking more time to load dynamic divs than static divs. How can I reduce the time it takes to load dynamic divs? This is the sample code I am using:
var ul_slide = document.createElement('ul');
var slide_div = document.createElement('div');
slide_div.setAttribute("class", "slide");
for (var i = 0; i < data.arrayItems.length; i++) {
alert(data.arrayItems.length);
var postId = data.arrayItems[i].postId;
var tag = data.arrayItems[i].tag;
var li_slide1 = document.createElement('li');
var img_link1 = document.createElement('a');
var linka = "#" + postId;
img_link1.setAttribute("href", linka);
img_link1.setAttribute("class", "click");
var img_slide1 = new Image();
img_slide1.style.width = "159px";
img_slide1.style.height = "100px";
img_slide1.setAttribute("src",data.arrayItems[i].url);
img_link1.appendChild(img_slide1);
li_slide1.appendChild(img_link1);
ul_slide.appendChild(li_slide1);
slide_div.appendChild(ul_slide);
div.innerHTML = "";
div.appendChild(slide_div);
}

Set initial combobox selection DevExpress Razor

I simply want to have the "Area" value (which is one of the items) be selected when the view appears. This is what I have:
#Html.DevExpress( ).ComboBox( settings =>
{
settings.Name = "cmbFieldLevel";
settings.CallbackRouteValues = new { Controller = "Equipment", Action = "FieldLevelPartial" };
settings.Properties.ValueType = typeof( string );
settings.Properties.TextField = "AreaName";
settings.Properties.ValueField = "AreaID";
settings.Properties.EnableClientSideAPI = true;
settings.ClientSideEvents.DataBound = "function( s, e ){ cmbFieldLevel.SelectedItem = "Area"; } ";
}).BindList(FieldLevel.GetAreaFilters()).GetHtml()
Any clues?
2 ways I can think of.
If you change your ComboBox to ComboBox for you can specify the model's value
like so
#Html.DevExpress().ComboBoxFor(x => x.ParamOrderNo, settings =>
{
settings.Properties.ValueField = "OrderNo";
settings.Width = 200;
settings.Properties.TextField = "Name";
}).BindList(CeduleProductionMVC.ViewModels.ViewModelCeduleGlobale.GetCommandes()).GetHtml()
Also, you can set the SelectedIndex, if your combolist content is fixed, the index might always be the same everytime all the time. Also, If you list is not fixed, you might be able to make a method to retrieve the index and set in after that.