|
Paul Riley wrote:
Not even using ODBC.NET[^]?
I need to access a password protected Paradox table (not by choice ), and as far as I know there is no way to do that with ODBC. So I have a Managed C++ dll that uses the BDE directly to build me a Dataset.
Paul Riley wrote:
stephen woolhead wrote:
I could use the Hidden ID column and search by Primary key method to find the row in the dataset, it just seems wrong when there must be a direct link back to the row in the dataset somewhere.
There isn't, I'm afraid. DataSets and DataGrids are two completely unrelated things, Daatabinding just allows you to link them. You have to create your own link between records like that.
I have fianlly worked it out, looks something like this using the previous delete example...
BindingManagerBase cm = this.BindingContext[dg.DataSource] ;<br />
DataRowView drv = (DataRowView )cm.Current ;<br />
((DataRow )drv.Row).Delete () ;
I found this was a good link if you MSDN installed
ms-help://MS.MSDNQTR.2002APR.1033/vbcon/html/vbconConsumersOfDataOnWindowsForms.htm[^]
While there is no direct link between the dataSet and the DataGrid, there are container level objects that you can access that are looking after it for you.
Anyway, thanks for all your replies, they really helped.
Stephen.
|
|
|
|
|
stephen woolhead wrote:
I need to access a password protected Paradox table (not by choice ), and as far as I know there is no way to do that with ODBC.
Ick! No idea, but I suspect you're right.
stephen woolhead wrote:
I have fianlly worked it out ...snip...While there is no direct link between the dataSet and the DataGrid, there are container level objects that you can access that are looking after it for you.
I'm impressed. Didn't know such a thing existed, thanks. Glad to be of some help (if only pointing your mind in the right direction) and it seems I've learned something too
Paul
|
|
|
|
|
please read that code and solve my problem.
Given after that code.
///////////////////////////////////////////////////////////
<
public class Win32Hook
{
[DllImport("kernel32")]
public static extern int GetCurrentThreadId();
[DllImport( "user32", CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]
public static extern int SetWindowsHookEx( HookType idHook,
HOOKPROC lpfn,
int hmod,
int dwThreadId
);
public enum HookType
{
WH_KEYBOARD = 2
}
public delegate int HOOKPROC(int nCode, int wParam, int lParam);
private HOOKPROC hookProc;
public void SetHook()
{
hookProc = new HOOKPROC(this.MyKeyboardProc);
SetWindowsHookEx(HookType.WH_KEYBOARD, hookProc, 0,
GetCurrentThreadId());
}
public int MyKeyboardProc(int nCode, int wParam, int lParam)
{
return 0;
}
}
To install the hook procedure
Win32Hook hook = new Win32Hook();
hook.SetHook();
///////////////////////////////////////////////////////////
Above code is 100% correct but my problem here is that I want to execute it for each thread for that purpose I modify a line of code and that is
SetWindowsHookEx (HookType.WH_KEYBOARD, hookProc, IntPtr.Zero,0 );
But after changing that line of code it does not solve my problem because MyKeyboardProc function does not execute its code.
I don’t know why? Can any body give its solution?
r00d0034@yahoo.com
|
|
|
|
|
Passing 0 as last parameter value (dwThreadId) complicates a bit things. MSDN says that in this case, the hook procedure must reside in a DLL. See for yourself what's said about lpfn :
lpfn
[in] Pointer to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn parameter must point to a hook procedure in a dynamic-link library (DLL). Otherwise, lpfn can point to a hook procedure in the code associated with the current process.
hMod
[in] Handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.
dwThreadId
[in] Specifies the identifier of the thread with which the hook procedure is to be associated. If this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I'm trying to create a treeview that is populated with the directory structure of the computer (like the left hand window of explorer). I can use System.IO.Directory or System.IO.DirectoryInfo to extract subdirectories for a given root (e.g. C:\) and add them to my tree, but ideally I'd like to start at Desktop and include My Computer (and then A:\,C:\,D:\,etc) just like explorer does. Does the .NET framework have any classes that allow you to move through that hierarchy, i.e. return everything listed under Desktop and then everything under My Computer, etc?
Thanks
|
|
|
|
|
Check out Environment.GetFolderPath(Environment.SpecialFolder.DesktopFolder) .
Paul
|
|
|
|
|
please read that code and solve my problem.
Given after that code.
///////////////////////////////////////////////////////////
>>><<<><
public class Win32Hook { [DllImport("kernel32")] public static extern int GetCurrentThreadId(); [DllImport( "user32", CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)] public static extern int SetWindowsHookEx( HookType idHook, HOOKPROC lpfn, int hmod, int dwThreadId ); public enum HookType { WH_KEYBOARD = 2 } public delegate int HOOKPROC(int nCode, int wParam, int lParam); private HOOKPROC hookProc;
To install the hook procedure
Win32Hook hook = new Win32Hook();
hook.SetHook();
///////////////////////////////////////////////////////////
Above code is 100% correct but my problem here is that I want to execute it for each thread for that purpose I modify a line of code and that is
SetWindowsHookEx (HookType.WH_KEYBOARD, hookProc, IntPtr.Zero,0 );
But after changing that line of code it does not solve my problem because MyKeyboardProc function does not execute its code.
I don’t know why? Can any body give its solution?
r00d0034@yahoo.com
|
|
|
|
|
I'm trying to implement a drag and drop between the windows shell and a windows form but although I implement the drag event nothing happens, when I drag a file. I also cannot find any examples on the topic.
Any ideas?
|
|
|
|
|
You may look this implementation[^].
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I am building a custom control in C# out of existing controls. One question I have:
Normally, when a control such as a TextBox is added to a Form, it is declared as private but as a member of the form, the Textbox.Text for example, is acessible for coding in the form. With a custom control, if I declare the controls as private, they are not directly accessible to the form the control is placed on. Should I declare the individual controls as protected or public members in the custom control and the custom control as private? Will this protect the data members or is the another way that would be better?
When you come to a fork in the road, take it! Y. Berra
|
|
|
|
|
Adding set/get properties in your custom control allows to inoculate the public interface from the actual custom control implementation. Hence lower code maintenance for instance when a TextBox becomes a MyTextBoxEx.
Of course, no one needs to care that much about object-oriented programming, and the controls could be declared as public. This would btw shorten development time. And there is no need to feel the same for it, especially when things are obvious.
Unfortunately, there is no known option (or I don't know) to tell the VS.NET IDE to add controls as public, instead of private.
My -0.5 cent
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
StephaneRodriguez wrote:
Unfortunately, there is no known option (or I don't know) to tell the VS.NET IDE to add controls as public, instead of private.
In the properties window there is a property called Modifiers in the Design category; that will let you set the class visibility for the control.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
The Modifiers property applies to an existing control, and on a one-by-one basis. Of course, I admit there is a challenge here for those willing to write the code automating this to the whole set of child controls.(can't figure out by the way why there is no Modifiers property at the Form level, this would have been a nice place for all controls added later).
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
StephaneRodriguez wrote:
The Modifiers property applies to an existing control, and on a one-by-one basis
In most cases you can select multiple controls and set the Modifiers property for all of them.
So far the only time I've found that you can't is when the control you are selecting comes from the base class. That makes sense because the forms designer uses the compiled assembly to do its work, so it obviously can't modify the visibility of the variable in the assembly.
StephaneRodriguez wrote:
can't figure out by the way why there is no Modifiers property at the Form level, this would have been a nice place for all controls added later).
This would be a nice addition for those that would like to expose all controls easily.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Thanks for all your comments and especially your perspective on OOP. I know there can be valid reasons to limit access but it seemed overkill to write a get/set and set the value to anything the user wants to anyway! I shall try to judiciously use public members.
don
When you come to a fork in the road, take it! Y. Berra
|
|
|
|
|
I cannot figure out if there are any methods to get the windows resolution in .NET at run time?
Acutally I have a window that resizes according to the data and I want it to center itself on the screen.
Any idea how to do it with pure .NET?
Thank you
|
|
|
|
|
Try this in your constructor:
this.StartPosition = FormStartPosition.CenterScreen;
Last week I stated that this woman was the ugliest woman I had ever seen. I have since been visited by her sister and now wish to withdraw that statement.
-Mark Twain
|
|
|
|
|
If setting the StartPosition property doesn't work, you can get the screen resolution by using the Screen class.
Screen screenRect = Screen.GetWorkingArea(this);
this.Location = new Point(
(( screenRect.Width - this.Width ) / 2) + screenRect.Left,
(( screenRect.Height - this.Height ) / 2) + screenRect.Top
); The reason I add screenRect.Left and screenRect.Top is because in a multi-monitor situation the top-left corner of the screen might not be (0, 0).
Untested code, but that *should* work
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
This one really looks great. I'm goint to try it as soon as I return to my development os. I suppose screen is a .net class. I haven't noticed it - too many classes, too much to learn Thank you!
|
|
|
|
|
Zinj wrote:
I suppose screen is a .net class.
Yes, I forgot to mention that, the full name is System.Windows.Forms.Screen
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
and I think I have used Rectangle for the declaration
|
|
|
|
|
Hello,
Does anybody know how can I convert color in HSB format to RGB ??
(from RGB ro HSB I can use Color class)
<br />
Color cl=Color.FromArgb(64,128,162);<br />
float h=cl.GetHue();<br />
float s=cl.GetSaturation();<br />
float b=cl.GetBrightness();<br />
But Color hasn't got any SetHue, SetSaturation or SetBrightness method
Thank you
|
|
|
|
|
Hi
Someone post a method a few months back in this forum, do a search for HSB, you should find it easily.
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Here is the link[^]
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I thought it was you
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|