Link to home
Start Free TrialLog in
Avatar of rohan_dim
rohan_dim

asked on

Help needed for my Borland C++ Application - TStringGrid

There is one TStringGrid on my Form and its size is bigger than my form size i.e property ColCount of StringGrid is set to 18 and RowCount is set to 26 and DefaultColWidth is set to 94 and DefaultRowWidth is set to 31. Thus Scroll bar will automatically appear on Form

Now I have placed one ComboBox on row 23 of StringGrid and written code that will move this ComboBox in each and every cells (cols) of rows 23,24 and 25. i.e i am taking values for these cells using ComboBox component.

Now problem is whenever i use to click on ComboBox and select one value then after selection the ComboBox value is placed in that cell and automatically the whole screen
scrolls up back to the top. i.e. again and again i have to scroll down and select value in ComboBox. So its quite tiresome and tedious work to enter values for these
rows (23,24,25) using ComboBox as screen scrolls up again and again. But ComboBox is needed to enter values for these rowsfor my application. Thus ComboBox component is necessary for me to keep there on StringGrid.

If anybody have solution to stop this auto screen scroll movement on ComboBox selection in StringGrid then plzzzzz let me know. Thanx in advance. waiting for reply ......
ASKER CERTIFIED SOLUTION
Avatar of DrDelphi
DrDelphi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rohan_dim
rohan_dim

ASKER

Hi Dr. Delphi
thanx for your kind reply. Your code and suggestion didn't help solve my problem. Problem still persists and even using TopRow property of StringGrid, screen scrolls up back to top at ComboBox exit event.
I don't see how that is possible...except that your variable is scoped local to a certain routine and not be acccessed by the OnExit routine. You may want to debug the value of sPos upon entry into the OnExit event to make sure that it is what you'd excpect to see.

Hi DrDelphi,
I thought your answer would definatly work bcoz u r dam confident of this solution using TopRow property. I am not at that level who will make silly mistakes regarding scope variables but i tried your code and solution and instructions again and still its not working. Form jumps back to top of screen.

I guess this problem might be bcoz StringGrid use to locate its top value or top cell pixel value, so that it can identify which cell has been clicked. Now problem still persists and i am not able to stop that auto form scroll problem.

If i use StringGrid whose height is not greater than form height then definatly it works bcoz StringGrid gets its top pixel as complete StringGrid is visible in client area. Problem is only when i increase rows and cols and height of StringGrid which will not fit in visible screen area and so IDE will add vertical scroll bar to Form.
okay, okay... my bad... I didn't see the part where the grid was larger than the form. Still not a problem tho... Write the Form's VertScrollBar position and the StringGrid's toprow off to variables in the OnEnter of the Combobox. Then reset both in the OnExit. Game, set and match. <g>


This question didn't show any activity for more than 21 days. I will ask Community Support to close it unless you finalize it yourself within 7 days.
You can always request to keep this question open. But remember, experts can only help if you provide feedback to their comments.
Unless there is objection or further activity,  I will suggest to accept

    "DrDelphi"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
========
Werner
Force accepted

** Mindphaser - Community Support Moderator **