|
OK lets say that I have a very big DB and I want to put it in a grid now when i load the app it takes very long how can i fix that or if is not fixable how can i make a progress bar incrementing while it loads?
The second problem is that all records are in the grid and when i try to filter the grid by some values writen in an edit box again it take long to filter?
Thx
|
|
|
|
|
You are correct. Binding massive amounts of data into a datagrid can be very slow and, although the datagrid provides a built-in paging mechanism, it functions in memory, after the result set to be bound has already been returned (adding to delays).
Your best bet is to implement custom paging and load only a page worth of data at a time. This is a well-known, well-covered issue, and there are some very good articles on codeproject.com as well as here[^].
Filtering should, again, be something you do when requesting your result set from the DB, but assuming you are binding your grid to a DataView, you should be able to implement filtering in your code-behind as well; just be sure to re-bind the grid's datasource after executing the filter.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi every one...
I've a DataGrid with a DataView as DataSource & it cells colors changed according to their values however.......
the DataView is updates frequently & if the order changed of the columns according to the new comming values all cells change their colors... this is not what I want....
so I want to know how to find out if the rows order was changed in the DataView .......sp Plz help me
A.Mohsen
|
|
|
|
|
How can implement Drag-and-drop operation between applications?
|
|
|
|
|
The same way you do within an application. Handle the ItemDrag event (or whatever is appropriate, or even just implement dragging yourself) and serialize your data in a format that can marshal across application boundaries, like text. If you're just trying to pass a control reference it won't work because that control is owned by the application from where you're dragging. If you serialize it, however, you can deserialize it in the other application (be sure to use a unique clipboard format (a string in the .NET implementation of drag and drop that wraps OLE's drag and drop)) and add it as a new control.
If you click "Search comments" above and search this forum (always a good idea to try first) and search for "drag drop" you'll find many examples, including several posts where I've discussed cross-application drag-n-drop as well as serializing and clipboard formats.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
hi,
i m using a dll built in vc++ 6.0 that is returning a BYTE* for image and its corresponding BITMAPINFOHEADER, Now i want to display this image through a picture box (if posible)using C#
Please Help Me
|
|
|
|
|
If you're receiving a pointer to a byte array, it should be fairly easy.
Create a MemoryStream instance using the byte array in the constructor, then create a new Image instance from the stream.
Example:
public Image LoadPic(byte[] serialImage)<br />
{<br />
System.IO.MemoryStream stream = new System.IO.MemoryStream(serialImage);<br />
return System.Drawing.Image.FromStream(stream);<br />
}
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
thanks for your reply but i was still not able to solve the problem
first q i want to ask is that i am allocating size of image/its byte array exectly the length X width (640*48)is it right cause bitmapinfoheader is also giving me the same length
the problem now is that; on the line
"return System.Drawing.Image.FromStream(stream);"
it is causing
"An unhandled exception of type 'System.ArgumentException' occurred in system.drawing.dll
Additional information: Invalid parameter used."
Please help me out
thanks
|
|
|
|
|
Is there anyway of having a dataset that is linked to my access database in such a way that when the database changes the dataset automatically updates itself?
|
|
|
|
|
The idea of ADO.net is to work on databases without an active connection so i wouldn't have thought so. You could get the program to create the connection every X Minutes / Hours and update the dataset accordingly.
Kev
|
|
|
|
|
Hi guys,
yeah here i am having one standard (0,0) co-ordinate at top ,left of the page and in that page my image is rotated any where.
so i want to find out rotation angle and translation factor.I got the rotation
angle means at what rotation my image must be at (0,0) co-ordinate but i want to find out translation matrix of GDI+ of DX,DY.
now here is situation where i got stuck.
suppose i am having (3,5) point which is left,top point of my image and i want the matrix of that and after getting that matrix i want to translate it by using
matrix.Translate(,) method so after getting translate i got my image at (0,0) point and how the matrix of that represent the element?
can anybody tell me out.
thanks.
regards,
montu3377
|
|
|
|
|
IIRC, if you have a point (3, 5) that you want to appear at (0, 0), you'd simply call TranslateTransform(-3, -5, MatrixOrder.Prepend).
But I'm not sure, I don't have anything to test it right now.
Yes, even I am blogging now!
|
|
|
|
|
Hi,
yeah you are right but this is this method is same as Matrix.Transform(-3,-5,matrix.append)?
and how can i got the element of that matrix?
i just need the confirmation about that.
thanks.,
regards.,
montu3377
|
|
|
|
|
Trying to create a dynamic button as follows:
initilized
this.button2 = new System.Windows.Forms.Button();
this.button2.Location = new System.Drawing.Point(80, 128);
this.button2.Name = "button1";
this.button2.Size = new System.Drawing.Size(120, 23);
this.button2.TabIndex = 8;
this.button2.Text = "Create Appointment";
this.button2.Click += new System.EventHandler(this.button1_Click);
It compiles with no errors but is not displayed
any hellp is greatly appreciated
|
|
|
|
|
|
I wish to prevent AutoPlay from happening when my .NET application is running. According to MSDN (http://msdn.microsoft.com/msdnmag/issues/01/11/autoplay/default.aspx[^], there are two methods for accomplishing this:
1) Handle the "QueryCancelAutoplay" windows message. This only works when your application is in the foreground and activated.
2) Implement the IQueryCancelAutoPlay COM interface and register with the ROT (Running Object Table)
I found an article for the first method at http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20695207.html[^]. However, my application isn't always in the foreground. Therefore, I am left with option 2. The big question I have is, how do I implement the IQueryCancelAutoPlay COM interface and register it at runtime with the ROT using C#?
~mykey
What do you get when the devil goes bald? Hell Toupee.
|
|
|
|
|
myker wrote:
The big question I have is, how do I implement the IQueryCancelAutoPlay COM interface
That's the easy part:
Compile the shobjidl.idl from the Platform SDK (where IQueryCancelAutoPlay is defined) to a .tlb file with the IDL compiler. Then, add a reference from your project to this .tlb file.
myker wrote:
register it at runtime with the ROT using C#?
That's the hard part, but I found a sample for you here:
http://www.dotnet247.com/247reference/msgs/49/245964.aspx[^]
Yes, even I am blogging now!
|
|
|
|
|
Wow, take a dependency on an interop assembly just ot implement the interface? It's a simple interface to implement and I'll post the solution in my direct reply if you're interested. It's a good approach for larger interfaces or many interfaces, however.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath Stewart wrote:
Wow, take a dependency on an interop assembly just ot implement the interface? It's a simple interface to implement and I'll post the solution in my direct reply if you're interested. It's a good approach for larger interfaces or many interfaces, however.
Ok, ok, I didn't use the [ComImport()] and [Guid()], but I was lazy and didn't want to convert the IDL to C#
Also, the point was to show him how to implement the interface, and tlbimp.exe is easily accesible from the IDE, I avoid explaining more than one thing per answer, because this can lead to confusion.
Yes, even I am blogging now!
|
|
|
|
|
The first reply will lead to an extra, rather large assembly that not necessary for this one simple interface with a single method. Just declare it in your project like so:
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("DDEFE873-6997-4e68-BE26-39B633ADBE12")]
public interface IQueryCancelAutoPlay
{
[PreserveSig]
int AllowAutoPlay(
[MarshalAs(UnmanagedType.LPWStr)] string pszPath,
[MarshalAs(UnmanagedType.U4)] int dwContentType,
[MarshalAs(UnmanagedType.LPWStr)] string pszLabel,
[MarshalAs(UnmanagedType.U4)] int dwSerialNumber);
} Implement that in a class with its own GuidAttribute (always hard-code your GUIDs, be they CLSIDs or IIDs) and [ClassInterface(ClassInterfaceType.None)] so that the CLR does not auto-generate a class interface for you. You should always follow good COM practices when coding COM interop in .NET.
You'll then need to register an instance of your implementation class in the Running Object Table. To do this you'll need to P/Invoke GetRunningObjectTable and CreateClassMoniker and use the UCOMIRunningObjectTable and UCOMIMoniker interfaces defined under System.Runtime.InteropServices :
[DllImport("ole32.dll")]
static extern int GetRunningObjectTable(
[MarshalAs(UnmanagedType.U4)] int reserved,
ref UCOMIRunningObjectTable);
[DllImport("ole32.dll")]
static extern int CreateClassMoniker(
Guid g,
ref UCOMIMoniker); (Note that neither of these functions gets defined when you create an interop assembly like how the first reply states).
To register your implementation class, then, instantiate it. In the following code, I assume the reference variable is called qcap :
int cookie = 0;
UCOMIRunningObjectTable rot;
if (GetRunningObjectTable(0, ref rot) == 0)
{
IMoniker mk;
if (CreateClassMoniker(new Guid("your class's GuidAttribute value"),
ref mk) == 0)
{
rot.Register(0, qcap, mk, ref cookie);
}
} Because this is a weak reference, you should not need to explicitly revoke your registration, but it's not a bad idea to do anyway. What I recommend is implementing the IDisposable pattern on your class and call UCOMIRunningObjectTable.Revoke passing the cookie I referenced above.
[EDIT]
I forgot that you must also register the CLSID (the same as for the implementation class) under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\CancelAutoPlay\CLSID\{YOUR CLSID}. To do that and still support registration via regasm.exe, define a couple of static functions that use the Registry and RegistryKey classes and attribute those functions with the ComRegisterFunctionAttribute and ComUnregisterFunctionAttribute . regasm.exe will execute these appropriate in addition to normal registration.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Friends I need your help because I want to print any document in a printer 3700dn whit mirror out,I need this in c#.Help me please because I´ve found this problem in many pages and the result have been null,I wait that anyone bring me any help
Thanks
S.
bigmega
|
|
|
|
|
In C++ you could use negative co-ordinates to flip an image when you BitBlt. You could import this from the dlls if C#/GDI+ does not do the same.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi, I am having problem using Win32 SendMessage function to send a string from one process to another in a C# Windows Form app. I am using .Net 1.1 SP1 on a Windows XP Pro box.
What I am trying to do is to restrict user from running multiple instances of a windows form app. When they do "MyWindowsFormApp.exe userArgument", I want to pass "userArgument" to current running instance of the app.
Here is the code
/***dll import part***/
[DllImport("User32.dll", EntryPoint="SendMessage")]
public static extern int SendMessage( int hwnd, int uMsg, int wParam, [MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)] string lParam);
/***code that sends message***/
//this returns currently running process of my application.
Process process = GetCurrentInstance();
//get first argument
string s = GetArgument();
//send argument Win32.WM_USER = 0x0400;
SendMessage(process.MainWindowHandle.ToInt32(),Win32.WM_USER, 0, s);
/***code in main form of MyWindowsFormApp that receives message***/
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case Win32.WM_USER:
IntPtr intPtr = m.LParam;
string str = Marshal.PtrToStringAuto(intPtr);
string str2 = (string)m.GetLParam( typeof(string) );
break;
}
}
Sending message part seems working(not exception thrown) and the WndProc method in the windows form IS receiving the message.
Problems are:
intPtr.ToInt32() always returns 1242424. Marshal.PtrToStringAuto(intPtr) always returns a empty string.
and (string)m.GetLParam( typeof(string) ) throws a MissingMethodExcpetion ("No parameterless constructor defined for this object.")
What am I doing wrong? Any suggestion will be greatly appreciated!
LS
|
|
|
|
|
Liu Shuai wrote:
What am I doing wrong? Any suggestion will be greatly appreciated!
Sorry, I don't know, but a few things you could try:
1. Try to first change the code to SendMessage in-process to check if the problem is between processes.
2. Try to SendMessage a WM_SETTEXT to some control (e.g., a textbox) to check if the problem is happening when sending the string or receiving it.
Yes, even I am blogging now!
|
|
|
|
|
Thanks for the response Daniel. I did those two testes.
1. SendMessage in-process is giving me the same (invalid) result
2. WM_SETTEXT works...
but isn't WM_SETTEXT sending string too?
|
|
|
|
|