|
You need to reset the location properties of each control every time the left or right button is pressed. However, I would suggest that you would be better redesigning your form. Most users hate having to jump through hoops like this just to do their work.
|
|
|
|
|
The TableLayoutPanel isn't really a visible control. It's a kind of framework that add properties to the controls it "contains" and modifies the functionality of the layout properties of those controls.
If it were me that had to implement some kind of side-scrolling, I'd put the TableLayout and controls on a Panel control the width required to accommodate all of the controls, then stick that in another Panel that is the width of the viewable area and set it's AutoScroll property to True.
But, I wouldn't be doing something like this unless I absolutely had no other choice. It's a kludge design that makes your application a bit harder to use and visualize data.
|
|
|
|
|
Aren't Control1 .. Controln the buttons to select the result pages 1 .. n for your DataGridView? In that case I would suggest not creating n buttons but just three (or how many you want to show at maximum) and change their display-text and click-"interpretation" dynamically. So after a click on next, Control1 will change its displayed text from 1 to 2 and when clicked would trigger page 2 to be shown instead of page 1, etc.
|
|
|
|
|
sorry , but these are not buttons. this question is not related with my previous questions. These are different controls( Most of them are TextBox and Combobox )
|
|
|
|
|
Alright, nevermind then
But I have to agree with Richard and Dave - I wouldn't recommend doing that. Wouldn't it be possible to just show all controls at once?
|
|
|
|
|
The following code is supposed to redirect the call to the Excel Calculate Method to my own function (MeMsg)
After running the HookCOMFunction routine , the Test Macro successfully executes the MeMsg replacement function as expected .. So far so good
However, when executing an excel calculation via the User Interface (not via code) such as by pressing the F9 key , the MeMsg replacement function doesn't get called ... I thought that replacing the 'Calculate' VTable offset address with the address of my replacement function would also work everytime excel is calculated via the User Interface
Any thoughts anyone ? My goal is to hook the excel Calculate Method via code as well as via the UI
Regards.
Code :
Option Explicit
Private Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" ( _
Destination As Any, _
Source As Any, _
ByVal Length As Long _
)
Private Declare Function VirtualProtect Lib "kernel32.dll" ( _
ByVal lpAddress As Long, _
ByVal dwSize As Long, _
ByVal flNewProtect As Long, _
lpflOldProtect As Long _
) As Long
Private Const PAGE_EXECUTE_READWRITE As Long = &H40&
Sub HookCOMFunction()
Dim pVTable As Long
Const lFuncOffset As Long = 84
CopyMemory pVTable, ByVal ObjPtr(Application), 4
VirtualProtect pVTable + lFuncOffset, 4&, PAGE_EXECUTE_READWRITE, 0&
CopyMemory ByVal pVTable + lFuncOffset, AddressOf MeMsg, 4
End Sub
Private Function MeMsg(ByVal voObjPtr As Long, ByVal Param As Long) As Long
MsgBox "Excel 'Calculate Method Hooked !!"
End Function
Sub Test()
Application.Calculate
End Sub
|
|
|
|
|
Where did you get this "HookCOMFunction" thing from?
That's where you MIGHT get help with it.
It is very unlikely you're ever going to get an answer to this question here as what you're doing is so far off the beaten path. You're in uncharted territory with hooking an Excel function.
You are the only person I have ever heard asking any kind of question like this in 12 years on CodeProject.
|
|
|
|
|
Hi Dave, Thanks for answering
I didn't get the HookCOMFunction from anywhere .. It is my code .. Matt Curland's book "advanced Visual Basic" touches on the subject of overriding COM Methods
This is similar to hooking Windows API functions which can be done with VB as well .. unfortunately, unlike when redirecting API calls , overrinding COM Methods works ONLY (at least for me) when the hooked Method is called via code and not via the User Interface
Do you know if there is a section on this website about COM/interfaces ? or any other place where I can ask ?
Regards.
|
|
|
|
|
Look down the left side navigation and you'll see the COM forum under General Programming.
I haven't read the book at all, but what I think the book is touching on is just providing an implementation of COM interface methods.
If you're talking about Windows Hooks, that's not API "hooking". I think what you're calling "hooking" is actually called "API Interception", usually done with a technique called "DLL Redirection". Windows Hooks are a very different concept where Windows provides various opportunities to participate in various function "pipelines", such as processing and altering keyboard and mouse messages before the messages are sent to their destinations for processing.
|
|
|
|
|
Yes. you are right Dave .. "DLL Redirection" is the right name and not "API hooking" such as when subclassing windows to intercept sent messages or when installing Mouse/Keyboard or CBT hooks etc
The question still remains open about how to make the code I provided for overriding COM Methods work when the Methods are called via the User Interface
I have searched everywhere but without any luck .. Hopefully someone knowledgeable can shed a light on this
Regards.
|
|
|
|
|
Like I said, you're in uncharted, or at the very most, very rarely ever tried, territory.
Good Luck.
|
|
|
|
|
Bump ..
Any thoughts on this anyone else ?
|
|
|
|
|
Hello !
Is there any possibility to modify the number of rows that a datagridview can show instantly ?
For example a datagridview can show 12 record instantly.
On runtime , is possible to make a modifications in order that the datagridview to show 10 records instantly ( the remaining datagridview area can be empty ).
Thank you !
|
|
|
|
|
What do you mean by "can show instantly"? The vertical size of the DataGridView?
|
|
|
|
|
I mean can show together in one page.
I want to modify this number ( but without changing the datagridview vertical size. )
|
|
|
|
|
If you don't use the DataGridView in databound-mode then you can set the number of rows displayed with its .RowCount -property. In databound-mode that is not possible.
|
|
|
|
|
No it's databound-Mode.
So you think there's no possibility to do that ?
|
|
|
|
|
If you want to restrict the amount of rows in databound-mode then you have to restrict the amount of rows in the datasource.
If your datasource is a DataView of a DataTable with some integer as primary key (or just any unique integer column) you could use the .RowFilter -property of the DataView to filter from the total rows the rows that should currently be displayed, e.g.:
dataView.RowFilter = "idColumn >= 10 AND idColumn < 20"
If the values of that column aren't consecutive you would have to scan the rows before and determine the actual value of that column at the position that should be the last on the page.
|
|
|
|
|
If a apply a filter , then the vertical scrollbar will be hide , and the user may think that there are no more records in the gridview.
|
|
|
|
|
The vertical scrollbar doesn't hide when applying a filter, unless the filter restricts the amount of rows to less than the height of the DataGridView. If that's not true for your DataGridView the reason must be somewhere else.
|
|
|
|
|
Yes , but if you read my first post , this is what I want t o do.
Actually gridview has for example , 36 records and he show 12 records per page.
I want to reduce this number for example to 10.
but the total height of 10 records is less than gridview height , so if I apply a filter to show 10 records , the vertical scrollbar will be hidden.
|
|
|
|
|
Alright, but what would a visible scrollbar change about the user possibly thinking that there are no more records when he scrolls to the end but in fact there are still more records? You will have to indicate that by something better than a scrollbar. Didn't you want to display something like <prev> 1 2 3 4 5 <next>? That would inform the user about more records.
|
|
|
|
|
the reason why I want this behavior , is because sometimes the last record on a page is not full displayed.
So the gridview shows 12 , but the last record is not full displayed. so I want to reduce the number to 11 or 10.
I know that I can make this by changing the gridview's height on design to full display the last record, but on runtime the user can resize the row's height so will be the same situation
|
|
|
|
|
|