powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / FoxPro, Visual FoxPro [игнор отключен] [закрыт для гостей] / Связанные таблицы и AfterRowColChange
2 сообщений из 2, страница 1 из 1
Связанные таблицы и AfterRowColChange
    #34527999
Pr0teus
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Есть два GRID'а, один содержит данные, второй значения агрегатных функций по колонкам. Оба grid'а связаны между собой. Единственный глюк, который пока не удается победить, это когда в grid'е с данными есть заблокированная колонка и невидимая, и скролинг осуществляется с помощью навигационных клавиш или TAB. В этом случае иногда в grid'е с данными незаблокированные колонки сдвигаются влево значительно больше, и повторить такой сдвиг для grid'а с агрегатами с помощью DoScroll(5) не получается, т.к. данные колонки полностью попадают в видимость и DoScroll не срабатывает. В итоге колонки расходятся, что не есть гуд :( Может кто-нибудь уже решал подобную проблему, отзовитесь.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
  case cEvt = 'afterrowcolchange'
  
    *the following never fires when LockColumns >  0 
    if  not this.oSourceGrid.LeftColumn == This.LeftColumn  
      If this.oSourceGrid.LeftColumn > This.LeftColumn  
        *scroll to R
        i= 0 
        do while this.oSourceGrid.LeftColumn > This.LeftColumn  
          i = i +  1  
          This.DoScroll( 5 )
          if i >= this.ColumnCount 
            this.oSourceGrid.DoScroll( 4 )
          endif
        enddo
      else
        *scroll to L
        do while this.oSourceGrid.LeftColumn  < This.LeftColumn 
          This.DoScroll( 4 )
        enddo
      endif
    endif

    *try to solve LockColumn >  0  case
    if this.LockColumns >  0 
      
      *the only way seems to be checking ActiveColumn/RelativeColumn
      iArow = this.oSourceGrid.ActiveRow
      iACol = this.oSourceGrid.ActiveColumn 
      iRCol = this.oSourceGrid.RelativeColumn
      
      *temporary unbind source grid ARCC, Scrolled
      Unbindevents(this.oSourceGrid,'AfterRowColChange',this,'eventHandler')
      Unbindevents(this,'Scrolled',         this,'eventHandler')

      *this seems to be needed to avoid flickering
      thisform.LockScreen = .T.
      
      *column changed in locked portion, scroll both to left
      if iACol <= this.oSourceGrid.LockColumns
        
        this.oSourceGrid.Doscroll( 6 )
        for i= 1  to  5   &&should be enough
          this.DoScroll( 6 )
        NEXT
        
      else  
        
        this.SetFocus() 
        
        *very interesting next stuff, ActivateCell work relatively to locked columns
        *need to compare Column index for a given RelativeRow and scroll accordingly
        this.ActivateCell( 1 , iRCol)
         
        iACol_1 = this.ActiveColumn 

        if not iACol_1 == iACol
        
          if iACol_1 > iACol
            for i= 1  to iACol_1 - iACol 
              this.DoScroll( 4 )
            next 
          ELSE
            
            for i= 1  to iACol - iACol_1 
              this.DoScroll( 5 )
            next 
            
          ENDIF
          
        endif 
        
        this.oSourceGrid.SetFocus()
*       this.oSourceGrid.Visible = .T.  && закоментирвал, т.к. у меня есть невидимые колонки
      endif
...
Рейтинг: 0 / 0
Связанные таблицы и AfterRowColChange
    #34528018
Pr0teus
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Не знаю на сколько корректно, но вроде получилось.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
        *very interesting next stuff, ActivateCell work relatively to locked columns
        *need to compare Column index for a given RelativeRow and scroll accordingly
        this.ActivateCell( 1 , iRCol)
         
        iACol_1 = this.ActiveColumn 

        if not iACol_1 == iACol
        
          if iACol_1 > iACol
            for i= 1  to iACol_1 - iACol 
              this.DoScroll( 4 )
            next 
          ELSE
            
            for i= 1  to iACol - iACol_1 
              this.DoScroll( 5 )
            next 

            *--------------------------------------------------------
            *еще одна проверка на несовпадение колонок
            iACol_2 = this.ActiveColumn 
            
            * выполняем DoScroll для grid'а с данными
            IF iACol_2<iACol THEN
              FOR i= 1  TO iACol - iACol_2 
                this.oSourceGrid.Doscroll( 4 )
              NEXT
              FOR i= 1  TO iACol - iACol_2 
                this.oSourceGrid.Doscroll( 5 )
              NEXT
            ENDIF
            *--------------------------------------------------------

          ENDIF
          
        endif 
        
        this.oSourceGrid.SetFocus()
*       this.oSourceGrid.Visible = .T.  && закоментирвал, т.к. у меня есть невидимые колонки


...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / FoxPro, Visual FoxPro [игнор отключен] [закрыт для гостей] / Связанные таблицы и AfterRowColChange
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]