DataGridView is not painted properly - winforms

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.

Related

Codenameone Form content with large list objects keep bouncing back to top of form

I'm trying to create a container with a sizable number ( > 20 or a number that exceeds the screen height) of items as a scrollable list using BoxLayout, it works (ie you can see the content moving up and down when one swipes) but trying to view items at the bottom of the list always results in the content pointer going back to the top of the list. The expectation is scrolling down the list will lock the view to where the scroll action ended. I also tried using TableLayout but the results are the same. Any ideas? the mainform below also has the setScrollableY() set.
int rows = 30;
Form hi = new Form("Test",new BoxLayout(BoxLayout.Y_AXIS));
hi.setScrollableY(true);
Container contents = new Container(new BoxLayout(BoxLayout.Y_AXIS));
contents.setScrollableY(true);
hi.add(contents);
for (int i = 0 ; i < rows;i++)
{
Label type = new Label("ROW+"+i);
type.setName(i+"");
type.setTextPosition(Component.TOP);
contents.addComponent(type);
}
mainform.addComponent(hi);
Remove this line:
contents.setScrollableY(true);
You can only have one scrollable container in a hierarchy and you chose the Form. When you nest scrollables the gesture gets picked by one of them and it becomes an issue. Unlike the desktop where you can click on a specific scrollbar in a refined way, in touch devices you can't pick a specific container to scroll.

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

Extjs - Scroll to last row (selected item)

I want to scroll to last row or selected item or rowIndex
I try some case like:
grid.setScrollTop(rowIndex); // not working
grid.getView().focusRow(rowIndex);// not working
// not working
var idx = this.getStore().indexOfId(rowIndex);
var rowEl = this.getView().getRow(idx);
rowEl.scrollIntoView(this.getGridEl(), false);
all of them are not working, how can i do that thanks
Edit:
I have a window include a gridpanel and when i add a new item i want scroll of window to last thanks
Edit 2:
see my example: http://jsfiddle.net/h9Dy9/ When i add some new items scroll of window must move to last or select items.
Last row, it means the bottom of the grid right?
I tried to use this, and it works:
var scrollPosition = 100;
YourGrid.getEl().down('.x-grid-view').scroll('bottom', scrollPosition, true);
I found this from Grid -scrollTo bottom

GXT Grid Layout issue - No Vertical Scrollbar

I'm trying to add a Grid into a VerticalLayoutContainer of fixed size (250 px) and have the user be able to scroll vertically.
I'm using the following code, however, the grid does not display at all.
VerticalLayoutContainer vPanel = new VerticalLayoutContainer();
vPanel.setHeight("250px");
vPanel.add(grid, new VerticalLayoutData(1, 1));
grid.setHeight("auto");
add(vPanel);
The Grid displays in other circumstances, but covers up other GUI elements (no scrollbar).
Hopefully this is an easy fix for those more experienced with Sencha GXT.
Thanks to anyone taking the time to help me out...
try this:
vPanel.getScrollSupport().setScrollMode(ScrollMode.auto);
If it doesn't work, then, try this:
`
ContentPanel p = new ContentPanel();
p.setHeaderVisable(false);
p.setBodyBorder(false);
p.setBorder(false);
p.setHeigh(250);
vPanel.add(p);
p.add(grid);
`
then grid, will automaticaly have scroll mode.
I had the same problem with a Grid in a ContentPanel, that is, the grid didn't show a vertical scrollbar. I used ContentPanel#forceLayout immediately after adding the grid to the panel, and it resolved the problem. Here's the actual code:
Grid<Pet> grid = new Grid<>(listStore, columnModel);
grid.setBorders(true);
grid.setColumnReordering(true);
grid.setLoadMask(true);
grid.setSelectionModel(selectionModel);
grid.setView(createGridView());
ContentPanel contentPanel = new ContentPanel();
contentPanel.setHeaderVisible(false);
contentPanel.add(grid);
contentPanel.forceLayout(); // <---- this is the line that fixed the problem!

Ultrawingrid - Row Appearance issue

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.

Resources