|
Hi John,
Hey Great... this worked. Thank you very very much for the help.
|
|
|
|
|
hi,
How can i cast datasource of a datagrid to a datatable.
I tried this block for that. But no result
DataTable dt=((DataTable)this.MicroGrid.DataSource) as DataTable;
Do u have any idea ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Actually, the code should be:
DataTable dt = (DataTable)MicroGrid.DataSource;
You might want to check the type of the DataSource before you attempt to cast it to a DataTable. Not all DataSource s can be cast to a DataTable ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
Did you checked whether your answer is good enough to serve my purpose ?
Dear it is not working and i am getting a an error " specified cast is not valid ".
code block :
MicroGrid.Datasource=dataset.Table["xyz"].DefaultView;
DataTable dt = (DataTable)MicroGrid.DataSource;
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
sreejith ss nair wrote:
Did you checked whether your answer is good enough to serve my purpose ?
$#@*^@$$... Like I told you in my previous post. CHECK THE TYPE of DataSource before you try and cast it to a DataTable. Your DataSource is bound to a DataVIEW, not a table. You can't cast a DataView to a DataTable, so therefore, yes, "The specified cast is not valid."
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
My old post is a sample senario that i shown to you.
DataTable dt = (DataTable)MicroGrid.DataSource;
this also not working.
In my application, using a data adapter i am filling "Employee Table Data" into a dataset and store it in "EMP" table.
Adapter.fill(Dset,"EMP");
After this, i set the datasource of my grid(MicroGrid) to Dset.Tables["EMP"];
MicroGrid.Datasource=Dset.Tables["EMP"];
Then i tried this below mentioned lines of code
DataTable Dt=(DataTable)MicroGrid.Datasource
Still i am getting same error ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi everybody,
How do I programmatically minimise and hide the console window in C# .NET ?
It is a console application.
Any help will be greatly appreciated.
Thanx in advance
saleem
|
|
|
|
|
One possible way would be through the use of the Win32 function FindWindow which will give you the HWND or Handle to the command window. Once you have the HWND you can call ShowWindow passing SW_MINIMIZE as the nCmdShow parameter. That should get you started.
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
const UInt32 SW_HIDE = 0 ;
const UInt32 SW_SHOWNORMAL = 1 ;
const UInt32 SW_NORMAL = 1 ;
const UInt32 SW_SHOWMINIMIZED = 2 ;
const UInt32 SW_SHOWMAXIMIZED = 3 ;
const UInt32 SW_MAXIMIZE = 3 ;
const UInt32 SW_SHOWNOACTIVATE = 4 ;
const UInt32 SW_SHOW = 5 ;
const UInt32 SW_MINIMIZE = 6 ;
const UInt32 SW_SHOWMINNOACTIVE = 7 ;
const UInt32 SW_SHOWNA = 8 ;
const UInt32 SW_RESTORE = 9 ;
const UInt32 SW_SHOWDEFAULT = 10 ;
const UInt32 SW_FORCEMINIMIZE = 11 ;
const UInt32 SW_MAX = 11 ;
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi.
I want to access to all object on the form like sqlDataAdapters,DataSets and ... .
(Form.Controls not contain the sqlDataAccess like objects)
|
|
|
|
|
The Non-Controls are instance variables. You can get all variables with System.Reflection:
<br />
FieldInfo[] arrInfo = form.GetType().GetFields();<br />
foreach(FieldInfo info in arrInfo){<br />
Console.WriteLine(info.Name + " - " + info.GetValue(form));<br />
}<br />
|
|
|
|
|
hi,
Corinna John Wrote
The Non-Controls are instance variables
i have a small doubt.
see the line below
TextBox txt=new TextBox();
txt.Name="sadas";
this.Controls.Add(txt);
so this "txt" instance fall in which section non-control section or control section. And "txt" of which type ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
There is one instance of the TextBox class. You can't access objects directly, you need a variable of the object's type to reference the object.
The first variable is txt . It's a local variable in your example.
Controls.Add(txt) copies the variable, but not the object. That means, you have one object with two references. The first reference is still txt , the second one is the new item in the Controls collection.
If you use the Forms Designer to drag a new component onto a form, it generates code for an instance variable private TextBox txt , and more code to create the object new TextBox() . the variable txt is an instance variable of the form, referencing the TextBox. And there's an additional reference the the TextBox in the Controls collection.
|
|
|
|
|
thank you.
I use this approach, but i can not obtain my desired object and change its value .
for example i want to get an sqlDataAdapter object and change one of its properties.
please guide to me.
|
|
|
|
|
Is your object not in the array? Then maybe you have to use different BindingFlags:
<br />
fields = form.GetType().GetFields( BindingFlags.NonPublic | BindingFlags.Instance );<br />
if( info.GetValue(form) is SqlDataAdapter ){<br />
}<br />
|
|
|
|
|
|
hi,
TehMedic Wrote :
Form.Controls not contain the sqlDataAccess like objects
You mean controls are not object of their base ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I think he means all the visual components he dragged onto the form in the VS Designer.
The Designer creates instance variables for the components, and displays a little box for each one. No matter if you drag a control or another icon onto the form, the Designer always creates an instance variable und writes code to create and initialize the object.
The controls can be found later on in the form's Controls collection, just like any other control. But there's no collection for the non-controls, they are nothing but instance fields that are initialized in InitializeComponent.
|
|
|
|
|
Hello All
I'm working in a LAN monitoring software one of it's feature is to shut down it's clients. Can anybody guide me which classes to explore to shut down a remote pc form ur C# Applcation. I'll be thankfuk for ur guidance.
God bless
Riz
|
|
|
|
|
Hello jinn_baba,
I do not know if there are any native .NET class library functions that you can use to perform remote machine shutdowns. However, you certainly can use the native Win32 APIs to do the job.
The main API is InitiateSystemShutdown(). You would also need to adjust your pvivileges to have the SE_REMOTE_SHUTDOWN_NAME privilege. For this would would need the following APIs :
OpenProcessToken()
LookupPrivilegeValue()
AdjustTokenPrivileges().
Regards,
Bio.
|
|
|
|
|
It needs to be done using the method spelled out by Bio. There is no .NET native class or method to do this.
You would have to have Administrator rights to the target machine or at least the Shutdown priv as directed by Bio.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanx to both of U. what do u think to use WMI (Ihave listend). and how to use it in C#
Regards Gosh
|
|
|
|
|
Does anyone out there know if it is possible to have the graphics object preserve what is drawn to it. If you consider programs such as AutoCAD, where the user would perform a variety of operations resulting in a drawing displayed on screen. Now if the user minimises AutoCAD and restores it again there is no noticeable time spent repainting the drawing window. This can also be seen when you drag a smaller window around over the drawing area where the invalidated regions of the drawing area take no noticeable time to repaint. Now if you consider a basic .NET windows form, which has, its background property (Image) set to an existing bitmap and you minimise and restore the form and drag a smaller window around over the form you will see a noticeable lag repainting the invalidated regions that resulted from the smaller window being dragged around over it.
Is there a way to have windows preserve what is draw to it so that the OnPaint()
method need only be called when there are changes to make to what is displayed?
|
|
|
|
|
When you get a message to minimise the window, you could first do a screenshot, and use that to render the screen state when maximised ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Well, to address your last questions, yes, OnPaint should already have a an update rectangle (knowledge derived from WM_PAINT, don't know the equivalent .NET property, my help is at work). Then you only need to refresh that rectangle.
In more general terms, as already stated, storing a bitmap of your area is a common technique. Then all you have to do for a OnPaint is blit the bitmap to the screen. Of course, you still need to generate this bitmap when ever the user does something.
Another idea is use Windows Metafiles. (Again, since I don't have my docs, I'm speaking about win32). Creating a metafile will give you a HDC, which you then paint on top of. Then you can "replay" then metafile to any other HDC (screen, printer, bitmap, whatever).
Since my company develops utilities for AutoCAD, I can say that it uses MUCH more complex mathematical routines. In general tho, it caches the geometry that is visible on the screen for quick updates. Perhaps it even has more then one cache.
Somewhere in CodeProject (I think, maybe somewhere else) someone wrote a "persistent" canvas that remembered what was drawn to it (TCL/TK has it built in). If you need, I could dig it up.
--
Joel Lucsy
|
|
|
|
|
Thanks for the response and for the suggestions.
I had already tried drawing to an off screen bitmap, but it still results in some lag when repainting (Well in my books anyway). If you could dig up the "Persistent" Canvas example I would really appreciate it.
|
|
|
|