I know this is probably really stupid, but I am looking for a way to reference a control from a class. If I change the control from 'private' to 'public static', I have no problem using the control. Except that I have to change all the reference from this.myControl to myForm.myControl.
When I switch back and forth between code and design view, the IDE will remove all of my changes.
Can anyone lend a quick helping hand. Thanx In Advance
If this is an instance of a control, you shouldn't access it from a static. Just have an public instance property that returns the control from the instance of that class. It would be much better, though, if you only expose what you need from that class. This is known as data-hiding - you don't want to expose too much information or allow unverified code to change the behavior of your class. If you want the property to only be visible in your assembly, use the internal access modifier instead of public.
A control and a window are distinct window classes with different window styles. Instead of having to modify window styles and going to the work of implementing a pump, simply host the control in a borderless form and return the dialog result from the form:
publicstatic DialogResult Load(MyFakeWindow window)
Form f = new Form();
f.FormBorderStyle = FormBorderStyle.None;
window.Dock = DockStyle.Fill;
DialogResult result = f.ShowDialog();
I was wonder if anyone ran into this problem before, if so could help me. I am trying to insert data into a database from a textbox. Once the user enters the data and presses the add button the database sould be updated and move to the next record. My problem is when the user presses add,I get the following error:
An unhandled exception of the type 'System.Data.SqlClient.SqlException occurred in system.data.dll
The code is as follows.........Thanks in advance!!!!!!!
If you're filling a DataSet with a SqlDataAdapter, may I also assume that you're binding it to your controls? In this case, just call SqlDataAdapter.Update passing the changed DataSet (the adapter will get the changes and execute the appropriate SqlCommand for the type of change, then will accept the changes on the DataSet). This very easy. To move to the next record, get the CurrencyManager for the bindings (see Control.BindingContext for more information) and increment or decrement CurrencyManager.Position to move forward or back respectively (check the curren position for 0 or Count - 1 before setting it, though, or an exception will be thrown for extending beyond the range of data).
missed dot must have caused compile time error so sth different occured.. I think you din't use right order to get access data in db. I mean you may not define sth properly such as a dataset.. We could not see the whole code. Good luck.
Is there any way to handle tcp syn packets without setting SIO_RCVALL socket options ?
The following works with icmp and udp msg but not with tcp connection requests.
System.Net.Sockets.Socket srv_socket=new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork,System.Net.Sockets.SocketType.Raw, System.Net.Sockets.ProtocolType.IP);
new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 2000)//whatever you want
srv_socket.Receive(ReceiveBuffer);// handles udp and icmp message but no tcp syn
Just about everybody will have seen or used this functionality I am trying to replicate, most likely in Acrobat viewer - or a variant which is [CTRL + Cursor] in most scrollable windows.
I am working on a simple image viewer, that overrides the onPaint for the form and renders a given image directly onto it (i.e. no picture boxes etc). Image display is working as it should but I am now looking for a way to scroll the form using mouse events. For example, the user clicks and holds on the form, when they move the mouse pointer the form is scrolled in the direction of mouse travel.
The mouse events to do this are relatively simple :
In a document/view architecture, the position of the document (or even an image in this case) must be tracked so that you know what view (the visible portion of a document or image to draw) to draw. Painting will happen regardless but you need to be able to track the position of where you were in order to know where to move (or rather, how to adjust the view).
He could do it this way but he would have to do all the view calculations himself and it's just not necessary. Even in games development with, say, DirectX you have a world view that you control and the painting of that world within that view is - for the purposes of this discussion - painted by DirectX (it just has to know how to paint).
See my reply to the original thread. Controlling the scroll bars is actually quite easy (though it could be easier if exposed by ScrollableControl or other non-derivative controls that can scroll like the ListView).
I had already tried that by using image offsets generated within the events I posted above.
Although it worked, the overhead was massive when painting dynamically (i.e. as the mouse moves), it worked acceptably if I just repainted on mouse up but it wasnt the exact functionality I was after.
One other method I came up with was using bitblt functions, using this system the overhead was reduced but not drastically, for the purposes of education and future forums searchers I will post the code up tomorrow.
I will attempt to use Heath's (post below) suggestion tomorrow, as it seems like a reasonable way of doing things.
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
You have to P/Invoke SendMessage and send the appropriate scroll messages to the control:
privatestaticexternIntPtr SendMessage(IntPtr hWnd, int msg,
int wParam, IntPtr lParam);
privateconstint WM_HSCROLL = 0x0114;
privateconstint WM_VSCROLL = 0x0115;
privateconstint SB_LINEDOWN = 1;
//... (more SB_ defines from winuser.h)// To scroll one line down...
SendMessage(myControl.Handle, WM_VSCROLL, SB_LINEDOWN, IntPtr.Zero);
myControl.Handle, of cousre, is the Window Handler of the control that you want to scroll, the owner of the scroll bar itself. See the documentation for WM_VSCROLL[^] and WM_HSCROLL[^] for more information.
The problem is that, although this will happily scroll right/down, it will not scroll up/left. After some reading of the MSDN links you posted I have been unable to locate the necessary codes to do this. Could you possibly point me in the right direction.
EDIT : After some more searching I found the following example, which set SB_LINEUP / SB_LINELEFT to 0 - interestingly this causes the my aplication to crash.
The definitions for the various SB_* messages are in the winuser.h file as I mentioned in a comment in the first code example I posted. You can find these in the Platform SDK, which - if you installed the default options when installing VS.NET - is in the VS.NET installation directory, the Vc7\PlatformSDK\include. There's a whole slew of them, and they have defined them in such a way that up/left is the same numeric value, as well as down/right. Both SB_THUMBPOSITION and SB_THUMBTRACK messages are sent as notification messages you can handle in an override of WndProc to scroll your control how you see fit.
Either use a positive width, or -1 to set the column width to the size necessary for the header text. -2 will set the width of only the last column to the remaining size. Doing this sequentially (since each row is the last column with each iteration) might lead to such odd behavior.