Ultrawingrid - Row Appearance issue - appearance

I am facing an issue with the appearance of the rows. Basically, I have added 2 appearances one for BackColor and the other for Forecolor, in the InitilizeLayout and used the Backcolor appearance in InitilizeRow. It works fine till then.
But when I use the forecolor appearance on some specific rows click of a button, it changes the forecolor appearance of all rows of the grid.
I am using below code:
InitializeLayout code:
lRowColorAppereance = e.Layout.Appearances.Add("GridBackColor")
lRowColorAppereance.BackColor = Color.LightGray
lRowColorAppereance.FontData.Bold = DefaultableBoolean.True
lIsMasterDBAppereance = e.Layout.Appearances.Add("IsMasterDB")
lIsMasterDBAppereance.ForeColor = Color.DarkGreen
InitializeRow code:
e.Row.Appearance = grdData.DisplayLayout.Appearances("GridBackColor")
Now, on click of a button when I change the Forecolor of my 0th row to lIsMasterDBAppereance.ForeColor OR Color.DarkGreen using the following code, it changes the Forecolor of all of the rows to DarkGreen.
Button click Event code:
lugrAddedRow.Appearance.ForeColor = grdData.DisplayLayout.Appearances("IsMasterDB").ForeColor
OR
lugrAddedRow.Appearance.ForeColor = Color.DarkGreen
But I don't want to change forecolor of all rows, I just need to change forecolor of some specific rows.
Can you please suggest If I am missing out something.

Related

Hiding element while preserving its space in page layout

I'm making a list of containers programmatically. These containers have a table layout with two cells. In first cell I'm showing a checkbox and in second cell is a multibutton:
In some rows I would like disable user to click on a checkbox. I've tried using .setHidden(true), setVisible(true), etc.. on a checkbox but in that case checkbox is not visible(which is also acceptable) but in that case it is not preserving it's space and data in rows are not vertically aligned(as you see in the image). Does anyone know how to achieve this??? Graying and disabling the checkbox would be great, but not showing it and preserving it's space would be acceptable.
Here's the code:
Container list = findContainerOrders(f);
list.setScrollableY(true);
LinkedHashMap htJSONObject;
//al is a ArrayList
for(int i=0; i < al.size(); i++){
htJSONObject = (LinkedHashMap)al.get(i);
Container cr = new Container();
TableLayout gr = new TableLayout(1, 2);
gr.setGrowHorizontally(true);
cr.setLayout(gr);
final MultiButton b = new MultiButton();
b.setName((String)htJSONObject.get("text1"));
b.setTextLine1((String)htJSONObject.get("text2"));
b.setTextLine2((String)htJSONObject.get("text3"));
b.setTextLine3((String)htJSONObject.get("text4"));
b.setUIIDLine1("MultiLine1");
b.setUIIDLine2("MultiLine2");
b.setUIIDLine3("MultiLine1Right");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
//some action here
}
});
CheckBox cb = new CheckBox();
cb.setName((String)htJSONObject.get("text1"));
String sSomeCondition = (String)htJSONObject.get("Condition");
//If this condition equals "NO" than I want to disable the checkbox
if (sSomeCondition.equals("NO")) {
// I've tried this but it doesn't work good
//cb.setHidden(true);
//cb.setHidden(true, true);
//cb.setVisible(true);
//cb.setEnabled(false);
//TODO - disable checkbox code....???
}
else {
cr.addComponent(cb);
}
cr.addComponent(b);
list.addComponent(cr);
}
When I use "setEnabled(false)" like Chen said in his answer, the checkbox is disabled but it's apperence is the same. I have a disabled style for my checkbox in my theme and I was able to change checkbox background but I want to change the color of the checkbox rectangle.
I tried to do that by adding constant "checkBoxUncheckDisImage" in a theme "Constants" tab and adding another image which would replace checkbox rectangle image but it didn't work.
How do I change the default checkbox image for a disabled checkbox?
setEnabled(false) should do the trick, make sure you have a disabled style for the CheckBox in your theme

SWT Combo with only dropdown arrow shown

I am looking for a SWT Combo where only dropdown arrow is shown in order to save space.
I found that setting a GridData.widthHint to the width of the arrow icon on the Combo might do the trick.
The question is how do I ask the Combo layout the exact width of the down arrow on the Combo so that I can set that as the widthHint?
Update:
Looks like even setting the widthHint = 0 still shows part of the text field. So any other ideas would be welcome.
I don't see a way to get the drop down button width. Messing around with the width hint is likely to be very platform dependent.
An alternative would be to use code similar to the CCombo control but without the Text field. This uses a Button with the SWT.ARROW | SWT.DOWN style:
Button button = new Button(parent, SWT.ARROW | SWT.DOWN);
When the button is pressed an SWT List control is displayed.

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.

Show Hide Silverlight Controls from the page

I have a dataGrid control on the page and below this grid there are some text boxes. in some conditions I dont want to display the grid on the page. For this I have used
dg.Visibilty = Visibilty.Collapse;
It will successfully hide the datagrid, which is fine, but the space that is consumned by the grid is still disply on the page, what I want is when my grid is hidden then controls will shift up automatically just like style=display:none ;
Thanks
What you are doing should work fine.
It might be that the container which contains your data grid might have some height width assigned.

Keep row permanently selected in the ListView in Win32

I am using Win32 ListView32.
When row in the ListView is selected it has dark blue color.
The row can be selected by either clicking on it or programmatically by calling ListView_SetItemState(hwnd, index, LVIS_SELECTED, LVIS_SELECTED);.
When ListView control focus is lost the selected row becomes gray.
How can I keep selected row with dark blue color irrespective of the focus?
Use the LVS_SHOWSELALWAYS window style. I don't think it can stay as dark blue as that's the indicator that that control has focus.
"Presumably you're doing this in a OnInitDialog handler? If so, you need
to SetFocus to your list control, and return FALSE from OnInitDialog."
If you are using VC6.0. You can set properties as "Show selection always" to ListView. And ListView will be defined by VC6.0 as LVS_SHOWSELALWAYS.
The definition of the CONTROL in resource file looks like:
CONTROL "List2",IDC_LIST_MEMBER,"SysListView32",LVS_REPORT |
LVS_SHOWSELALWAYS | LVS_EDITLABELS | WS_BORDER |
WS_TABSTOP,7,64,514,187
And The selected item will be highlighted. For my program, the default background color is white, the default selected and focused color is blue, and the default selected but lost focused color is gray(when usr click to other control).

Resources