powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / FoxPro, Visual FoxPro [игнор отключен] [закрыт для гостей] / Событие Scrolled
9 сообщений из 9, страница 1 из 1
Событие Scrolled
    #34489977
Pr0teus
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Почему, когда прокручивание grid'а осуществляется навигационными клавишами, не срабатывает событие Scrolled. Просто есть второй grid, расположение столбцов которого должно повторять расположение столбцов у первого грида. Как этого добиться??? И не спрашивайте почему, так надо 8) Во втором гриде показываются результаты агрегатных функций над столбцами при желании пользователя.
...
Рейтинг: 0 / 0
Событие Scrolled
    #34490071
Kruchinin Pahan
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Pr0teusПочему, когда прокручивание grid'а осуществляется навигационными клавишами, не срабатывает событие Scrolled. Просто есть второй grid, расположение столбцов которого должно повторять расположение столбцов у первого грида. Как этого добиться??? И не спрашивайте почему, так надо 8) Во втором гриде показываются результаты агрегатных функций над столбцами при желании пользователя.
Потому что Scrolled это событие полос прокрутки. Вынесите привязку второго грида в отдельную функцию, и вызывайте ее как из Scrolled, так и из AfterRowColChange
Кстати, я обычно еще делаю BindEvent на Resize и Move колонок. Тогда привязка получается практически идеальной.
...
Рейтинг: 0 / 0
Событие Scrolled
    #34490075
alex11100
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
ответ найдете в примере
...
Рейтинг: 0 / 0
Событие Scrolled
    #34490594
Pr0teus
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Спасибо 2 alex11100
...
Рейтинг: 0 / 0
Событие Scrolled
    #34665368
igorgorb
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
alex11100ответ найдете в примере

Прошу прощения, но Ваш пример не запустился без ошибок!
написал: "The data source for this object must be a variable reference"
при suspend встал на строчку: "this.Columns(j).ControlSource = [(]+Transform(aTotals )+[)]" в gridfooter.calctotal()

Хочеться понять и взять на вооружение, но после VB6, в VFP много чего используеться не так и это выбивает из колеи. Спасибо
...
Рейтинг: 0 / 0
Событие Scrolled
    #34665424
alex11100
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
сообщите какая версия vfp у Вас?
...
Рейтинг: 0 / 0
Событие Scrolled
    #34665859
alex11100
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
пример не мой, взят из интернета

на что необходимо обратить внимание

футер привязывается к основному гриду
oSrcGrd вот так
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
		BindEvent(oSrcGrd.Columns(i),'Resize',this,'eventHandler', 1 )
		BindEvent(oSrcGrd.Columns(i),'Moved',this,'eventHandler', 1 )
		BindEvent( oSrcGrd, 'Resize' , this, 'eventHandler', 1 )
		BindEvent( oSrcGrd, 'Moved' , this, 'eventHandler', 1 )
		BindEvent( oSrcGrd, 'AfterRowColChange' , this, 'eventHandler', 1 )
		BindEvent( oSrcGrd, 'LockColumns' , this, 'eventHandler', 1 )
		BindEvent( this, 'Scrolled',this,'eventHandler', 1 )



метод eventHandler
Код: 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.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
lparameters vParameter
local array aSrcObj[ 1 ]
local oObj, cEvt, cClass, i, nWorkArea,iARow,iACol, iRCol, iACol_1

AEvents(aSrcObj, 0 )
oObj = aSrcObj[ 1 ]
cEvt = Lower(aSrcObj[ 2 ])
cClass = Lower(oObj.BaseClass)
nWorkArea = Select(Alias())
this.Tag = 'evt'

Select(this.cRecordSourceCursor) 		&&to be sure that memvar evaluation doesn't conflict with other alias columns

do case
case cClass  = 'grid'
	do case
	case cEvt = 'resize'
		this.Width = oObj.Width
		this.Top = oObj.Top + oObj.Height
	case cEvt = 'moved'
		this.Top = oObj.Top + oObj.Height
		this.Left = oObj.Left
	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 

			*bind ARCC back to this
			Bindevent(this.oSourceGrid,'AfterRowColChange',this,'eventHandler',1)
			BindEvent( this, 'Scrolled',this,'eventHandler',1)

			thisform.LockScreen = .F.

		endif 	
	case cEvt = 'scrolled'
		if  not this.oSourceGrid.LeftColumn == This.LeftColumn  
			If this.oSourceGrid.LeftColumn > This.LeftColumn  
				*scroll to L
				i=0
				do while this.oSourceGrid.LeftColumn > This.LeftColumn  
					This.oSourceGrid.DoScroll(4)
				enddo
			else
				*scroll to R
				i=0
				do while this.oSourceGrid.LeftColumn  < This.LeftColumn 
					i = i + 1 
					This.oSourceGrid.DoScroll(5)
					if i >= this.ColumnCount 
						this.DoScroll(4)
					endif
				enddo
			endif
		endif
		if this.oSourceGrid.LockColumns > 0
			this.oSourceGrid.DoScroll(vParameter)
		endif 
	case cEvt = 'lockcolumns'
		this.LockColumns = this.oSourceGrid.LockColumns
	endcase
case cClass = 'column'
	do case
	case cEvt = 'moved'
		for i=1 to this.ColumnCount
			if this.Columns(i).ColumnOrder <> this.oSourceGrid.Columns(i).ColumnOrder
				this.Columns(i).ColumnOrder = this.oSourceGrid.Columns(i).ColumnOrder
			endif
		next
	case cEvt = 'resize'
		for i=1 to this.ColumnCount
			if this.Columns(i).Width <> this.oSourceGrid.Columns(i).Width
				this.Columns(i).Width = this.oSourceGrid.Columns(i).Width
			endif
		next
	endcase

endcase

this.Tag = ''
select  (nWorkArea) 	&&switch back work area 

попробуйте подсмотреть
и перенести в свое приложение (если необходимо)
...
Рейтинг: 0 / 0
Событие Scrolled
    #34666117
Фотография Aleksey-K
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Я делаю так:
Событие Scrolled "основного" Grid

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
LPARAMETERS m.nDirection
LOCAL m.lnSteps, m.i

*-- THIS.oAgrGrid - ссылка на итоговый GRID, которая хранится в "основном"

WITH THIS
	IF (m.nDirection >  3 )
		IF (TYPE("THIS.oAgrGrid") == "O") AND .oAgrGrid.Visible
			m.lnSteps = ABS(.LeftColumn - .oAgrGrid.LeftColumn)
			FOR m.i =  1  TO m.lnSteps
				.oAgrGrid.DoScroll(m.nDirection)
			ENDFOR
			.oAgrGrid.Refresh()
		ENDIF
		.Refresh()
	ENDIF
ENDWITH
Только не забудьте отслеживать и и изменении размеров (Resize) и положения (Moved) всех колонок "основгого" GRID с целью синхронного изменения соотв. колонок у итогового. Т.е. придется в "основном" GRID использовать свой класс Column.

С уважением, Алексей
...
Рейтинг: 0 / 0
Событие Scrolled
    #34666134
Фотография Aleksey-K
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Да, еще забыл сказать, что в событии AfterRowColChange необходимо добавить код:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
LPARAMETERS m.nColIndex
LOCAL m.lnSteps, m.lnDirect, m.i

WITH THIS
*-- THIS.oAgrGrid - ссылка на итоговый GRID
	IF INLIST(.RowColChange,  2 ,  3 ) AND ;
			(TYPE("THIS.oAgrGrid") == "O") AND .oAgrGrid.Visible
		m.lnSteps = ABS(.LeftColumn - .oAgrGrid.LeftColumn)
		m.lnDirect = IIF(.LeftColumn > .oAgrGrid.LeftColumn,  5 ,  4 )
		FOR m.i =  1  TO m.lnSteps
			.oAgrGrid.DoScroll(m.lnDirect)
		ENDFOR
		.oAgrGrid.Refresh()
	ENDIF
ENDWITH


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


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