Telerik winforms Grid View Header Title - winforms

i need to put a title header in Telerik Gridview in winforms.
i tried
radGridView1.MasterGridViewTemplate.Columns["myColumn"].HeaderText = "first line \n Second line \n third line";
but it doesn't work. my referred link :
http://www.telerik.com/community/forums/winforms/gridview/2-lines-of-text-in-the-column-header.aspx

I tested the following and it is working:
In the designer set AutoSizeMode = ColumnHeader
Then add this line of code:
this.radGridView1.Columns[0].HeaderText = "This is a \n multiline \n header text";
Please note that the index [0] is relevant my test code. You shall set your column index considering that the first column is 0.
This is the result I got:
Let us know if this works for you.

When you set the text as you mentioned, the text will be multiline, but the header cell height is not enough, hence you are not able to see that other lines. You can change the header cells height by using this property:
radGridView1.TableElement.TableHeaderHeight = 100;
radGridView1.MasterGridViewTemplate.Columns[0].HeaderText = "first line \n Second line \n third line";
Alternative way to do that is to use the AutoSizeRows property (set to true), but this will auto size all rows in the grid according to their content, not just the header row.

Related

Cn1 AutoSizeMode = true, hides text

Whenever I enable the autosize mode on my components, the label text dissapears
final CheckBox checkBox = new CheckBox();
checkBox.setText(text);
//checkBox.setAutoSizeMode(true);
m_content.add(m_textModeLayout.createConstraint(), checkBox);
final PickerComponent pickerComponent = PickerComponent.createStrings(opciones);
final Label labelForComponent = pickerComponent.getEditor().getLabelForComponent();
labelForComponent.setText(text);
//labelForComponent.setAutoSizeMode(true);
pickerComponent.onTopMode(true);
final TextComponent textComponent = new TextComponent();
final Label labelForComponent = textComponent.getEditor().getLabelForComponent();
textComponent.labelAndHint(text);
labelForComponent.setText(text);
//labelForComponent.setAutoSizeMode(true);
textComponent.onTopMode(true);
The problem I´m facing is that some of the texts are really big and I need a way for those to be displayed.
Thanks!
Autosize mode won't work here due to the unique layout constraint which prevents us from knowing the available size beforehand. It will only work in a deterministic layout.
I would suggest rethinking your design and using a SpanLabel below the text component to represent the additional details. That way the text won't shrink "too much".
An alternative would be setting the label size of the text to a specific smaller size but that might make the text unreadable to some users and make things worse as a result.

How to reduce the width of a TextArea used as String?

Still on my sidemenu from there, I've resolve the non broking text with a custom function that modify the text.
Now I'm stuck with the width of the component. I've change it from a SpanLabel to a TextArea in order to have more control on it's behaviour, but here is my problem: the TextArea width is too large as shown on the screenshot (put a ContentContainer UIID on to see the space occupied by the TextArea).
As you can see, the first component has a too large TextArea. I've set the column count of the TextArea to the length of the firstRow + 1, but it doesn't seem to take it in account.
The component is BorderLayout with a non grow center ScaleImageLabel and the TextArea on south. Is it a way to have a better width for the TextArea ? I would have it aligned with the image and with the area wrapped close to the text, but I really don't know how to achieve this...
Thanks in advance !
My suggestion is to use GridLayout for equal sizes or TableLayout with constraints for varying sizes for left and right components. It will prevent the TextArea from growing beyond a limit.
An example will be:
//GridLayout
Container cont = GridLayout.encloseIn(4, cmpL1, cmpR1, cmpL2, cmpR2)
//OR
//TableLayout with Constraint
TableLayout tl = new TableLayout(2, 2);
Container cont = new Container(tl);
cont.add(tl.createConstraint().widthPercentage(50), cmpL1);
cont.add(tl.createConstraint().widthPercentage(50), cmpR1);
cont.add(cmpL2);
cont.add(cmpR2);

SpanLabel in Codename one with BoxLayout along the y axis does not span

I need to show a list of labels one under another, but some labels may be on multiple lines. So I created a scrollable container with BoxLayout along the y-axis and tried to use SpanLabels, but it appears as a normal label. Am I missing something?
Form f = new Form("Span", BoxLayout.y());
f.add(new SpanLabel("Short"));
f.add(new SpanLabel("Not so short"));
f.add(new SpanLabel("Not so long as to line break"));
f.add(new SpanLabel("This should totally line break because it's getting to that length where it should have an effect"));
f.add(new SpanLabel("Short"));
f.add(new SpanLabel("Not so short"));
f.add(new SpanLabel("Not so long as to line break"));
f.add(new SpanLabel("This should totally line break because it's getting to that length where it should have an effect"));
f.show();
So I created a scrollable container with BoxLayout along the y-axis and tried to use SpanLabels, but it appears as a normal label. Am I missing something?
This was the key for not working. I called container.setScrollable(true), which made it scrollable in both x and y, so altough I used SpanLabel, it still showed on one line, since it can be scrolled horizontally. This:
this.container.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
this.container.setScrollableY(true);
this.container.setScrollableX(false);
Fixed it for me.

DataGridView is not painted properly

I have a DataGridView in a wizard which is created using TabControl. When this DataGridView is shown, a mixture of cell contents and previous wizard page is displayed. When I click next to show next wizard page and then go to previous page, DataGridView display correctly. I take a picture of this:
First cell from right in first row corrupted.
How can I fix this?
EDIT:
You can reproduce this bug this way: place a small DGV in a form. My DGV width is 268 and its height is 247. Add six columns to it. Put these lines of code in form load event method:
string[] row = new string[6];
for (int i = 0; i < 10; i++)
{
row[0] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
row[1] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
row[2] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
row[3] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
row[4] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
row[5] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
dataGridView1.Rows.Add(row);
}
Finally go to DGV properties then DefaultCellStyle and change BackColor to Transparent. Run and the only thing you need to do is to scroll to right. A picture of this problem:
I think the problem is Transparent color. Changing Transparent to some color other than Transparent will solve the problem but I do not know why.
Thank you .. yes this is related to Transparent colour , i have changed Transparent to White and my DGV works well.

Batch display of Tab spacing

Im making a batch game, and made a "email" screen which looked like this
echo - INBOX (1) -
echo - OUTBOX -
echo - SPAM (3) -
If I use TAB for spacing, the batch display is different than if I use spaces
(if I use Spaces, the batch file displays it looking like it does in notepad)
Why is this?
(Screenshot: http://db.tt/z4NGvhUz - Top is with Spaces, bottom is with tab)
The TAB is one character that, when it is displayed in the screen, it is expanded to the next 8-character tabulation position. A text that contains Tabs is shown differently depending on the text that appears before the first Tab. Spaces are always spaces and are always shown in the same way.

Resources