|
My project is CMat, with RderTable in RderDataSet with
columns Descr and Price. OrderEntryForm and ViewOrderForm with dataGridView1 in OEForm and reportViewer1 in VOForm.
reportViewer1 uses report1.rdlc with table1.
OEForm generated rderDataSet and rderTableBindingSource & VOForm generated RderDataSet and RderTableBindingSource when fields dragged from DataSource Window. I click a Button in OEForm to ShowDialog VOForm. I tried to insert
RderTableBindingSource.DataSource = rderTableBindingSource.DataSource or rderDataSet.RderTable
before, this.reportViewer1.RefreshReport in VOForm_Load
- error "does not exist in current context"
Please help me view the active Order entry table filled by rderDataSet.ReadXml, in a reportViewer1.
Ramith Sivanarain
-- modified at 9:52 Thursday 12th October, 2006
|
|
|
|
|
Hi everybody!
I want to scan the ports on my computer, and I'm looking for the right class to do that.
any clues please?
thanks!
|
|
|
|
|
Hi!
I'm not sure about this but you could try to do it like this:
<br />
System.Net.Sockets.TcpClient myclient = new System.Net.Sockets.TcpClient();<br />
for (int i = 0; i < 65535; i++)<br />
{<br />
try<br />
{<br />
myclient.Connect("localhost", i);<br />
}<br />
catch<br />
{<br />
}<br />
}<br />
This method is obviously not the best because it uses a try..catch statement and it will also throw an exception if a particular port is blocked by another application.
To get around this issue you will have to extend the exceptionhandling massively.
That's how i would do it but as already mentioned i'm pretty unexperienced...
Good luck,
mik
|
|
|
|
|
Hi
I thought about this method, but its really not an efficient one.
thanks alot anyway!
|
|
|
|
|
Good Morning,
i have a problem!
i have a form with a TextBox and DataGrid.
i fill a DataGrid with DataBase records
and when i select a record in DataGrid i show it in textbox!
But i want to type a character at textbox and automatically locate the record in DataGrid (Partial key search)!
Thanks a lot!
|
|
|
|
|
Hello,
you can use a Filter on the Datagrid:
At first, you must create a DataView on your table.
DataView dv = new DataView();
dv.Table = MyDataSet.Tables["Suppliers"];
Then you can set the RowFilter like this : dv.RowFilter = "City = 'Berlin'";
You can use different FilterOptions, like in SQL : dv.RowFilter = "Name = 'S%'";
S% -> All that begans with S
( Naturally it seems in you case like this : dv.RowFilter = "Name = '" + textbox.Text + "%'";
Then you choose the DataView as DataSource of the Grid
There are propably some errors im my example, but the logic is right
( I used it before 1 year and i still don't have the code here )
Good luck
|
|
|
|
|
thanks dude!!
i'll try it "Filter on the DataGrid"!!
if i find out anything else i´ll call you again!!!
cya!
|
|
|
|
|
can i enter a command line argument after installing application from clickonce technology
|
|
|
|
|
A command line argument to the click once application? Yes, but you have to take some steps to allow command line arguments. When publishing the ClickOnce app from Visual Studio, go into your project settings page, Options, then enabled "Allow URL parameters to be passed to your application". You can then pass parameters via a query string:
www.myclickonceapp.com/theapp.application?someParam=5
|
|
|
|
|
Hi,
I'm currently in the process of planning a Server-Client application and evaluating whether Remoting is a good way to go. I've already read some MSDN articles about remoting and also looked at some of the remoting articles here but there are still some questions:
1. Is the server side knowing which clients are currently connected?
What I currently know is that connected clients can instaniate and fetch objects from the server. Calls on functions on those objects may either be run locally or on the serevr side. Is it possible to determine on the server side which clients currently hold those objects? I know I could define functions so that clients can explicitely notify their connection or disconnection but I think about lost connections or client side crahes where no explicit call is possible anymore.
2. Can the server send messages to the clients?
In the examples I have investigated so far (mostly chat apps) the clients regulary poll for new data from the server. Is there a possibility that the server directly calls functions in all connected clients?
3. When a client makes a call in the server does this call create server side a new thread in which this call is processed? Is this the same for every call coming from the same client?
Robert
|
|
|
|
|
Robert Rohde wrote: 2. Can the server send messages to the clients?
In the examples I have investigated so far (mostly chat apps) the clients regulary poll for new data from the server. Is there a possibility that the server directly calls functions in all connected clients?
Yes, in fact, you can use the normal event mechanism to do that i.e server exposes an event and clients subscribe to it. There are a few gotchas though, like firewalls preventing incoming traffic. You would also have to make some config changes to allow clients to recieve calls (See TypeFilterLevel[^]).
Robert Rohde wrote: 3. When a client makes a call in the server does this call create server side a new thread in which this call is processed? Is this the same for every call coming from the same client?
Last I checked, remoting calls come in on a IOCP Thread. The .NET ThreadPool has a 1000 of them by default, in addition to the normal 25 threads per processor.
|
|
|
|
|
|
|
Hello,
I have written an application in c# and would like to set a shortcut key to start the application.
I would like to use ctrl+shift+h to start the application.
Also I would like the user to be able to change this shortcut key.
Can anyone help.
Thanks
cjm
|
|
|
|
|
you need to use system wide hook so that the os can intercept any key strokes and determine if it matches the ones you want then you process them and fire the application.
then you need a shortcut editor to change the shortcut by listening to the keys the user enters and rather than opening the program, assign it as the hotkey.
below is a class i found and adapted to suit my needs ( the class didn't have any copyright info in it and i can't remember where i found it, so i apologize if anyone is offended, although i did modify and improve it extensively )
DO NOT USE THIS CODE FOR MALICIOUS ACTIVITY, ELSE I WILL BE *VERY* DISSAPOINTED, AND YOU MAY GO TO HELL FOR IT!
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace GlobalKeyHook
{
public class KeyboardHook : IDisposable
{
#region Hook-dlls
[DllImport("user32", EntryPoint = "SetWindowsHookExA")]
private static extern int SetWindowsHookEx(int idHook, KeyBoardCatcherDelegate lpfn, int hmod, int dwThreadId);
[DllImport("user32.dll", CharSet = CharSet.Auto,
ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
private static extern short GetKeyState(int keyCode);
[DllImport("user32", EntryPoint = "MapVirtualKey")]
private static extern int MapVirtualKey(int wCode, int wMapType);
[DllImport("user32", EntryPoint = "CallNextHookEx")]
private static extern int CallNextHook(int hHook, int ncode, int wParam, KeybHookStruct lParam);
private const int
WH_KEYBOARD = 2,
WH_KEYBOARD_LL = 13;
[DllImport("user32", EntryPoint = "UnhookWindowsHookEx")]
private static extern int UnhookWindowsHookEx(int hHook);
#endregion
private bool m_DisableHooking = false;
public bool DisableHooking
{
get { return m_DisableHooking; }
set { m_DisableHooking = value; }
}
public KeyboardHook()
{
kbcatcher = new KeyBoardCatcherDelegate(KeyBoardCatcher);
keybhook = SetWindowsHookEx(WH_KEYBOARD_LL, kbcatcher,
Marshal.GetHINSTANCE(typeof(KeyboardHook).Module).ToInt32(), 0);
if (keybhook == 0)
throw new ExternalException("Error: " + Marshal.GetLastWin32Error().ToString() + "\r\nCould not hook keyboard");
}
public KeyboardHook(bool AddModifierData)
: this()
{
this.AddModifierData = AddModifierData;
}
#region Dispose
private readonly int keybhook;
private bool disposed;
public void Dispose()
{
if (!disposed)
{
UnhookWindowsHookEx(keybhook);
GC.SuppressFinalize(this);
disposed = true;
}
}
~KeyboardHook()
{
Dispose();
}
#endregion
private struct KeybHookStruct
{
public int vkCode, scanCode, flags, time, dwExtraInfo;
}
private delegate int KeyBoardCatcherDelegate(int code, int wparam, ref KeybHookStruct lparam);
public static bool CheckKeyPressed(params Keys[] keys)
{
for (int i = 0; i < keys.Length; i++)
if (!CheckKeyPressed(ref keys[i])) return false;
return true;
}
public static bool CheckKeyPressed(ref Keys key)
{
return CheckKeyPressed((int)key);
}
public static bool CheckKeyPressed(int vkey)
{
short ks = GetKeyState(vkey);
Console.WriteLine(ks);
return ks == 1;
}
public bool IsKeyPressed(Keys key)
{
return CheckKeyPressed(ref key);
}
public bool AreKeysPressed(params Keys[] keys)
{
return CheckKeyPressed(keys);
}
private const int HC_ACTION = 0;
[MarshalAs(UnmanagedType.FunctionPtr)]
private KeyBoardCatcherDelegate kbcatcher;
public event KeyEventHandler
KeyDown = null,
KeyUp = null;
private const int
wpKeyDown = 256,
wpKeyUp = 257;
public bool AddModifierData = true;
public readonly Keys[] Modifiers = { Keys.Alt, Keys.Control, Keys.Shift };
private int KeyBoardCatcher(int hookcode, int wparam, ref KeybHookStruct lparam)
{
if (HC_ACTION == hookcode)
{
if ((wparam == wpKeyDown && KeyDown != null)
|| (wparam == wpKeyUp && KeyUp != null))
{
try
{
Keys k = (Keys)lparam.vkCode;
if (AddModifierData)
k |= Control.ModifierKeys;
KeyEventArgs e = new KeyEventArgs(k);
if (wparam == wpKeyDown)
KeyDown(this, e);
else
KeyUp(this, e);
if (e.Handled) return 1;
}
catch { }
}
}
return CallNextHook(keybhook, hookcode, wparam, lparam);
}
}
}
in your main init it like this
KeyHooker keyhooker = KeyHooker.Instance;
when you want to disable it so you can process the keys in the 'key editor' or 'key assignor', do this
KeyHooker.Instance.DisableHooking = true;
then re-enable them on form close or after the hot key is decided with this
KeyHooker.Instance.DisableHooking = false;
hope that helps
g00fy
|
|
|
|
|
cheers dude. thats a lot of code but I will give it a go.
atb
cjm
|
|
|
|
|
hi,
i'm doing a windows service and i want the service to take a screen shot
every (time unit)....
is there any ready component for this.. or is this possible?
|
|
|
|
|
a little util class i wrote some time ago
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace ScreenShot.interop
{
public sealed class Desktop
{
[DllImport("user32.dll")]
internal extern static IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
internal extern static IntPtr GetDC(IntPtr windowHandle);
[DllImport("gdi32.dll")]
internal extern static IntPtr GetCurrentObject(IntPtr hdc, ushort objectType);
[DllImport("user32.dll")]
internal extern static void ReleaseDC(IntPtr hdc);
[DllImport("user32.dll")]
internal extern static void UpdateWindow(IntPtr hwnd);
[DllImport("user32")]
internal static extern IntPtr GetWindowDC(IntPtr hwnd);
[DllImport("user32")]
public static extern IntPtr GetForegroundWindow();
internal static Bitmap Capture()
{
try
{
IntPtr desktopWindow = GetDesktopWindow();
IntPtr desktopDC = GetDC(desktopWindow);
Bitmap desktopImage = GetBitmap(desktopDC);
ReleaseDC(desktopDC);
return desktopImage;
}
catch (Exception e)
{
ScreenShotConfig.persistance.Logger.Log(typeof(Desktop), "Capture(): " + e.Message);
return null;
}
}
internal static Bitmap GetBitmap(IntPtr imagePtr)
{
IntPtr hwnd = GetCurrentObject(imagePtr, 7);
Bitmap desktopImage = Image.FromHbitmap(hwnd);
return desktopImage;
}
internal static Bitmap GetForegroundWindowBitmap()
{
IntPtr handle = GetForegroundWindow();
IntPtr windowDC = GetWindowDC(handle);
IntPtr hwnd = GetCurrentObject(windowDC, 0);
Bitmap desktopImage = Image.FromHbitmap(hwnd);
ReleaseDC(windowDC);
return desktopImage;
}
}
}
call it with
Bitmap b = Desktop.Capture();
hope that helps
g00fy
|
|
|
|
|
I don't do a lot of this, but is there any reason you couldn't just:
Rectangle rec = Screen.PrimaryScreen.Bounds;
Bitmap screenCap = new Bitmap(rec.Width, rec.Height, PixelFormat.Format32bppArgb);
Graphics getScreen = Graphics.FromImage(screenCap);
getScreen.CopyFromScreen(rec.X, rec.Y, 0, 0, rec.Size, CopyPixelOperation.SourceCopy);
return screenCap;
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
No it didn't worked. It's creating blank screen. It's problem when we call from inside of Windows Service.
|
|
|
|
|
I have a question.
Right now i have made a server. It works just fine but there is a problem.
I need to push a button in order to recieve data. I would like suggestions (and examples)
how i can create a server wich regularly (always?) listens if data is sendt.
Can anyone help me with this?
|
|
|
|
|
In generally you solve this problem by using loops. Make a button "Start listening" which sets a bool variable, lets call it KeepListening, to true and call the listenfunction which contains a loop like
while (KeepListening)
{
// Put Receive-Code in here...
System.Threading.Thread.Sleep(10);
}
Now the second button sets the variable KeepListening to false. If you click it, the application will leave the loop.
If you want to make your application listen to incoming traffic and also being available for user inputs, you will have to use threads (create a listening thread).
There are nice threading-tutorials out there if you aren't familiar with threading at all. I'm too lazy/busy to search for a nice explanation but i will do if you are not successful.
Lets sum it up:
- You will have to use a Loop to listen all the time.
- You will have to make use of the multithreading if your application should be available for other tasks while listening.
Good luck,
mik
|
|
|
|
|
Yo Mik,
Tnx a lot for you're answer. I have read some tuts on threading but they are not really clear to me. If u have time and u know one please tell me . I'm not in a big hurry so ......
Again tnx.
|
|
|
|
|
okay, lets create a simple listening function and the eventhandlers for those buttons
<br />
bool KeepListening = false;<br />
<br />
public void button_StartListen_click(object sender, EventArgs e)<br />
{<br />
KeepListening = true;<br />
System.Threading.Thread myListenThread = new System.Threading.Tread(new System.Threading.ThreadStart(Listen));<br />
myListenThread.Start();<br />
}<br />
<br />
public void button_StopListen_click(object sender, EventArgs e)<br />
{<br />
KeepListening = false;<br />
}<br />
<br />
private void Listen()<br />
{<br />
while (KeepListening)<br />
{<br />
System.Threading.Thread.Sleep(10);<br />
}<br />
}<br />
Okay, thats how it could look like now lets see what exactly happens here.
If you click on the "Start Listening" Button, the method button_StartListen_Click is called and:
- Sets KeepListening to 'true'
- Initiates a new object of the Thread Class and pass one argument in its constructor.
- Starts the new Thread.
Now the thread is running in the background. The threads task is to call the method "Listen" with no arguments. When doing so the method won't exit until you click the "Stop Listening" button because of the loop.
If you click the "Stop Listening" button now the button_StopListen_Click method will:
- Sets KeepListening to 'false'
Setting the KeepListening variable to false will cause the loop condition (while (KeepListening)) to be not forfilled. This makes the method exit and the thread will do so too!
This is no explanation about threading since this is a very complex subject. You should start playing around with them because multithreading is what you want your application to do ;D
However, hope you understood what i was talking about - if the code example does not work i will start my ide and create a working example
|
|
|
|
|
Yo Mik ,
Its working perfect the only small problem i got left is when i want to add the recieved stuff to a listbox i get the following error :
Additional information: Cross-thread operation not valid: Control 'lbReceived' accessed from a thread other than the thread it was created on.
Any idea how i can fix this ?
Greetings ,
Jacco
|
|
|
|
|