Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » automatic scrolling in grid control Collapse All
Subject Author Date
ernest peters Nov 12, 2004 - 12:39 AM

I would like my control to update itself when data is dynamically entered at a predefined rate. (say every 500ms). i can get the data into the control without problems, but i cant seem to get it to scroll to the bottom without using the arrow keys or resizing the grids frame window.

Technical Support Nov 12, 2004 - 4:01 AM

Of course, you can update the grid data periodically with a 500ms timer or using some other method. If you need to make some cell visible, just invoke the following two methods of the grid control:

virtual bool EnsureVisibleColumn(
  LONG nColNo,
  bool bRedraw = true
  );
 virtual bool EnsureVisibleRow(
  LONG nRowNo,
  bool bRedraw = true
  );

Please note that you need to set bRedraw to false for the first method and to true for the second.

If you prefer to set focus on a specified cell whose value is updated periodically, use the method below (leave its default parameters intact):
virtual CPoint FocusSet(
  const POINT & ptNewFocus,
  bool bEnsureVisibleColumn = true,
  bool bEnsureVisibleRow = true,
  bool bResetSelectionToFocus = true,
  bool bRedraw = true,
  bool * p_bCanceled = NULL
  );
In both cases, the grid control will make visible the cell specified by its row and column index.

ernest peters Nov 14, 2004 - 6:04 PM

Still not working unfortunately..
This is my init code..can you tell me if this could be the cause? The problem is that my control (that sits within a CExtGridWnd dialog) wont scroll to the bottom of the grid when new data is added (only when the new line is outside the dialog, at which point the scroll bar should appear and the dialog should automatically scroll) . This init code was just used to play with the feature of your grid control..i will eventually make them changeable to the end user.
Init:
    SiwModifyStyle(__ESIS_STH_ITEM | __ESIS_STV_ITEM
| __EGBS_SF_SELECT_OUTER_ROWS
| __EGBS_SFM_FULL_ROWS
| __EGBS_SF_SELECT_OUTER_COLUMNS
| __EGBS_RESIZING_CELLS_MASK
| __EGBS_MULTI_AREA_SELECTION
| __EGBS_GRIDLINES
| __EGBS_DYNAMIC_RESIZING
, 0, false);

SiwModifyStyleEx(__EGBS_EX_HVI_EVENT_CELLS | __EGBS_EX_HVO_EVENT_CELLS // Track Mouse events (NEEDED)
| __EGBS_EX_HVI_HIGHLIGHT_ROWS
| __EGBS_EX_HVO_HIGHLIGHT_ROWS
| __EGBS_EX_HVI_HIGHLIGHT_COLUMNS
| __EGBS_EX_HVO_HIGHLIGHT_COLUMNS
| __EGBS_EX_HVI_HIGHLIGHT_CELL
| __EGBS_EX_HVO_HIGHLIGHT_CELL
, 0, false);

    BseModifyStyle(__EGWS_BSE_SORT_COLUMNS
| __EGWS_BSE_SORT_MULTIPLE_COLUMNS
| __EGWS_BSE_SORT_ROWS
| __EGWS_BSE_SORT_MULTIPLE_ROWS
| __EGWS_BSE_SORT_ANY_MASK
, 0, false);


RowRemoveAll( false );
    ColumnRemoveAll( false );
    OuterRowCountTopSet( 2L, false );
    OuterColumnCountLeftSet( 1L, false );
    OuterColumnWidthSet( true, 0L, 60 );
LONG nColCount = CCommsModule::Inst().mLogArray.GetSize();
//    ColumnAdd( nColCount, false );

    for( LONG nColNo = 0L; nColNo < nColCount; nColNo++ )
    {
CParameter *pe = CCommsModule::Inst().mLogArray.GetAt(nColNo);

this->AddItem(pe);
    }

My data implementation code is as follows:
void CLogWinDlg::Update(CParameterArray &arr)
{
int size = arr.GetSize();
CParameter *pe;
CString data;

this->RowAdd(1, false);
uint2 row = this->RowCountGet() - 1;

    CExtGridCellHeader * pCellHeaderAtLeft = STATIC_DOWNCAST(CExtGridCellHeader, GridCellGetOuterAtLeft(0L,    row, RUNTIME_CLASS(CExtGridCellHeader)));
    pCellHeaderAtLeft->ModifyStyle(__EGCS_HDR_FOCUS_ARROW_RESERVE_SPACE|__EGCS_HDR_FOCUS_ARROW_DISPLAY|__EGCS_HDR_ROW_COLUMN_NUMBER|__EGCS_TA_HORZ_RIGHT);

this->SetRedraw(false);

for (int i = 0; i < size; i++)
{
pe = arr.GetAt(i);
pe->GetData(0, 0, data);

        CExtGridCellStringDM * pCellString = STATIC_DOWNCAST(CExtGridCellStringDM, GridCellGet(i, row, 0, 0, RUNTIME_CLASS(CExtGridCellStringDM)));
pCellString->TextSet(data.GetBuffer());
}

this->EnsureVisibleColumn(1, false);
this->EnsureVisibleRow((this->RowCountGet()-1), true);

this->SetRedraw(true);
this->Invalidate();
this->UpdateWindow();
}

CLogWinDlg::Update is called by the timer.

Technical Support Nov 16, 2004 - 5:24 AM

Your source code looks absolutely correct. To clarify the problem, we need to take a look at your entire project. Can you send it to us without any internals not related to UI? We can remove unwanted references manually.

ernest peters Nov 16, 2004 - 6:25 PM

Hi again,
I managed to sort it out.. I was missing a OnSwUpdateScrollBars invocation after adding my new line into the grid.

Thanks again for your prompt response and help.