|
Missed a dot...
cmd.ExecuteNonQuery();
Free your mind...
|
|
|
|
|
Put your codes inside try/catch block so you can tell us what is error message.
Mazy
No sig. available now.
|
|
|
|
|
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).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
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.
GM
|
|
|
|
|
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);
srv_socket.Bind(
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
|
|
|
|
|
This function:
private void BuildMenuStructure(SqlDataReader dr)
{
ArrayList arrNodes = new ArrayList();
while(dr.Read())
{
object[] values = new object[dr.FieldCount];
dr.GetValues(values);
arrNodes.Add(values);
}
}
Places data from a datareader into a 2-dimensional arraylist.
How can i index into the data (arraylist).
I need to do something like this:
int mmenuid = arrNodes[1][1].ToInt32();
|
|
|
|
|
An ArrayList stores Object s and, as such, will return them. In order to access your object[] array you'll have to cast the return value of ArrayList.Item (the indexer):
int mmenuid = (int)((object[])arrNodes[i])[1];
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
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 :
private int mouseDownX;
private int mouseDownY;
private bool mouseDown = false;
private void ImageViewer_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
mouseDown = true;
mouseDownX = e.X;
mouseDownY = e.Y;
}
private void ImageViewer_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
mouseDown = false;
}
private void ImageViewer_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (mouseDown)
{
if (e.X > mouseDownX)
{
}
if (e.X < mouseDownX)
{
}
if (e.Y > mouseDownY)
{
}
if (e.Y < mouseDownY)
{
}
}
The problem is that I cant find any way of scrolling the form (this), does anybody know of a solution?
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
I think you should repaint the form when the mouse move, not scroll it. Thats the thing really happend there but of course it could be slow.
Mazy
No sig. available now.
|
|
|
|
|
Actually, Mazdak, the current position of the document is changed which cause repainting on the view of the document at that position.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Sorry Heat,I can't understand you. Is that mean its a wrong solution that I gave ? In his paint he should calculate the moving of mouse and show new image , isn't it?
Mazy
No sig. available now.
|
|
|
|
|
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 ).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Got it.
Mazy
No sig. available now.
|
|
|
|
|
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
> 42
|
|
|
|
|
You have to P/Invoke SendMessage and send the appropriate scroll messages to the control:
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg,
int wParam, IntPtr lParam);
private const int WM_HSCROLL = 0x0114;
private const int WM_VSCROLL = 0x0115;
private const int SB_LINEDOWN = 1;
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.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
That is great, its exactly what I was looking for, thanks lot for the code.
One question though: I implemented the follow code snippet :
private const int WM_HSCROLL = 0x0114;
private const int WM_VSCROLL = 0x0115;
private const int SB_LINEMOVE = 1;
and thend called this within the event I posted above
SendMessage(this.Handle, WM_VSCROLL, SB_LINEMOVE, IntPtr.Zero);
SendMessage(this.Handle, WM_HSCROLL, SB_LINEMOVE, IntPtr.Zero);
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.
http://www.vbdesign.net/expresso/archive/topic/2739.html
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
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.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have a Windows Form with an empty ListView control set to Details view.
I create this dialog and attempt to add the columns from the DataSet to the ListView, but I'm having a problem.
//lets fill the results box
for(int x=0;x
|
|
|
|
|
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.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
MSDN says -2 will set the width to the header text, its even used in the example...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistviewcolumnheadercollectionclassaddtopic2.asp
|
|
|
|
|
What I read - also in MSDN but regarding the List-View common control which ListView encapsulates - described what I said before. A slight discrepency somewhere, but it really matters not.
The following code worked fine for me (both the commented source, and the uncommented):
using System;
using System.Drawing;
using System.Windows.Forms;
public class Test : Form
{
public static void Main()
{
Application.Run(new Test());
}
public Test()
{
ListView lv = new ListView();
Controls.Add(lv);
lv.Dock = DockStyle.Fill;
lv.View = View.Details;
foreach (string s in new string[] {"Code", "Project", "Is", "Awesome"})
{
lv.Columns.Add(s, -2, HorizontalAlignment.Left);
}
}
} I didn't catch before that you were using DataColumn.ToString . There's the problem. If you look at the documentation for DataColumn.ToString (which it overrides, but be careful because classes that don't override it and inherit from Object.ToString will return their Type as string), you'll see that it returns DataColumn.Expression , which is used to filter and calculate values. Instead, use DataColumn.Caption . If the Caption is not set, the ColumnName is returned. If you prefer, you can set the Caption when creating a strongly-typed DataSet , or you can use the database column name or an ALIAS.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Very strange....I tried the following code and got the same results, a blank ListView:
for(int x=0;x<<dSet.Tables["Documents"].Columns.Count;x++)<br />
{<br />
ColumnHeader head = new ColumnHeader();<br />
head.Text=DateTime.Now.ToString();<br />
head.Width=-2;<br />
head.TextAlign=HorizontalAlignment.Center;<br />
lvResults.Columns.Add(head);<br />
}
but if I change the -2 to 80, the ListView looks normal....I don't understand...
(I used << intentionally because the single < was interpreted as HTML and chopping off my for statement)
|
|
|
|
|
For a <, use <
First, why not just set head.Text to dsSet.Tables["Documents"].Columns[x].Caption like I mentioned before? Read the documentation for ColumnHeader.Caption and you'll see why.
As far as this not working, you have set ListView.View to View.Details , right? ListView.HeaderStyle should also be set to something other than ColumnHeaderStyle.None .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I did try using ColumnHeader.Caption with same results, so I decided to use some other string (DateTime.Now.ToString() in this case) to see if it had anything to do with using ColumnHeader text as source. The problem is not the Text, I get the correct Text when I use ColumnHeader[x].ToString(), just the width of the columns are Zero unless i set the width to a positive value. Obviously this is not criticle, but I'd like to have the columns sized to their header, and now its kinda a mission to figure out why it doesn't work.
The following are the settings for the list view:
this.lvResults.AllowColumnReorder = true;
this.lvResults.ContextMenu = this.cmResults;
this.lvResults.Dock = System.Windows.Forms.DockStyle.Fill;
this.lvResults.FullRowSelect = true;
this.lvResults.GridLines = true;
this.lvResults.Location = new System.Drawing.Point(0, 0);
this.lvResults.MultiSelect = false;
this.lvResults.Name = "lvResults";
this.lvResults.Size = new System.Drawing.Size(536, 342);
this.lvResults.TabIndex = 0;
this.lvResults.View = System.Windows.Forms.View.Details;
this.lvResults.SelectedIndexChanged += new System.EventHandler(this.lvResults_SelectedIndexChanged);
And the HeaderStyle is set to Clickable.....
|
|
|
|
|
Hmm, this is strange. What happens when you compile and run that code fragment I posted earlier in this thread? What version of the Framework are you using? I'm just not seeing anything wrong with your code now that you've posted about everything pertinent.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|