|
Hi Everyone,
I have a question, and I really don't know how to make it works. The questio
ns is that I have a LinkButton Column on a DataGrid table.
:
protected System.Web.UI.WebControls.DataGrid dgInfo;
:
dgInfo.Items[j].Cells[1].Text = "MyData";
:
:
After I change the cell text to "MyData", the cell losts the link. Does ther
e have any way to change the LinkButton text to two different texts and keep
the link button attribute?
Thanks a lot ....
|
|
|
|
|
I would like to change the color of the FixedSingle BorderStyle in the PictureBox from Black to Red
How Can i Do it??
C# Winforms
|
|
|
|
|
Why can't the as operator perform user-defined conversions?
Is it a C# problem or with MSIL? I can't see any reasons why the compiler should'nt be able to use a user-defined conversion operator. Anyone knows the answer?
MSDN
my c# blog: C# Coach
|
|
|
|
|
I am confused... you never need to do that. Perhaps you are looking for explicit casting, but that will only work as reference type. Btw, have u looked at the output of an as expression in MSIL? That will show you the what actually happens when it is used.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Hi Everyone,
I have a question, and I really don't know how to make it works. The questions is that I have a LinkButton Column on a DataGrid table.
:
protected System.Web.UI.WebControls.DataGrid dgInfo;
:
dgInfo.Items[j].Cells[1].Text = "MyData";
:
:
After I change the cell text to "MyData", the cell losts the link. Does there have any way to change the LinkButton text to two different texts and keep the link button attribute?
Thanks a lot ....
|
|
|
|
|
I am creating a C# wrapper for a FORTRAN app. There are several cases where I have the FORTRAN writing to standard output and reading from standard input. I have seen several examples of how to redirect standard IO when you spawn a new process, but I want to know how to do something similar when you make calls to methods within a DLL.
<br />
[DllImport(@"waypoint.dll", EntryPoint="MAKETHIS")]<br />
public static extern void MAKETHIS(StringBuilder output);<br />
That's how i'm accessing the function within the DLL.
The reason why I don't just return a simple value is that the process takes over 2 minutes to complete (CPU intensive) so I want to read the status as the FORTRAN runs. The FORTRAN is outputting something like:
15 jobs done
30 jobs done
42 jobs done
48 jobs done
...
And so I want to catch this ouput from my C# wrapper.
I'm using Intel Visual Fortran (if that matters).
Thanks in advance for any input. :->
|
|
|
|
|
|
I've made some progress... I've been able to redirect the standard output to a text file using something like
<br />
[ DllImport( "Kernel32.dll" )] br />
internal static extern bool SetStdHandle( int nStdHandle, HandleRef hndRef); <br />
Then I assign a text file handle as follows:
<br />
FileStream fs = new FileStream( "output.txt", FileMode.Open );<br />
HandleRef hr = new HandleRef( fs, fs.Handle );<br />
<br />
uint STD_OUTPUT_HANDLE = 0xfffffff5;<br />
SetStdHandle((int) STD_OUTPUT_HANDLE, hr);<br />
I think I'm pretty close... now I want to somehow setup an arbitrary handle to ???? so that the output stays in memory and I can read it be redirecting standard input or something. Any ideas?
I REALLY want to try to avoid launching other processes just for what should be just a simple method call.
|
|
|
|
|
Larsenal wrote:
HandleRef hr = new HandleRef( fs, fs.Handle );
That will get you nowhere, its not the same thing. Why not write the output of the Fortran dll to a file instead of stdout? or create a callback in the fortran function to report progress. That you can use in C#.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
leppie wrote:
That will get you nowhere
Really? It actually redirects the stdout to the file as expected. I do not want to write to a file because I need to be able to read the output continuously from another thread. I am afraid I will run into problems with synchronization. Remember, the FORTRAN is doing a lengthy calculation and it spits its progress out to STDOUT. I want to just read that progress as it comes.
Are you suggesting opening, appending, and closing the file every time one more line of my progress becomes availalbe and then open, read and close the file from C# to check if there is any progress? Seems like a bad solution. Is there anything more elegant?
|
|
|
|
|
Anonymous wrote:
Seems like a bad solution.
The bad solution is printing to stdout from a dll.
Anonymous wrote:
Are you suggesting opening, appending, and closing the file every time one more line of my progress becomes availalbe and then open, read and close the file from C# to check if there is any progress?
Yes thats probably not good, but your example made me think thats what u are doing...
Going with a callback solution would be best, IMO.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
leppie wrote:
The bad solution is printing to stdout from a dll.
I agree... however, I don't have control over rewriting the DLL.
|
|
|
|
|
Hello,
With the Win32 API I could get a handle to the system icons by calling LoadIcon with a NULL instance handle (eg. hIcon = LoadIcon(NULL, IDI_HAND) ).
How can I get the system stop icon in totally managed way? (without P/Invoke)
[EDIT: And if I require P/Invoke, what's the equivalent of MAKEINTRESOURCE ?]
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Sorry about the vote of 1. I wasn't thinking and clicked the wrong link.
For questions like this you really should consult the header. If you look at the definition for the MAKEINTRESOURCE in Winuser.h (which is documented as the header in which it's declared in the Platform SDK documentation), you'd see:
#define MAKEINTRESOURCEA(i) (LPSTR)((ULONG_PTR)((WORD)(i)))
#define MAKEINTRESOURCEW(i) (LPWSTR)((ULONG_PTR)((WORD)(i)))
#ifdef UNICODE
#define MAKEINTRESOURCE MAKEINTRESOURCEW
#else
#define MAKEINTRESOURCE MAKEINTRESOURCEA
#endif // !UNICODE What's going on here? Well, certain APIs like LoadIcon want a string, and since an integer isn't a string you need to pack the integer into a string which the API will handle.
To declare a similar macro (or, rather, a method) in C# isn't nearly as straight forward, since a short (same as a WORD ) isn't a string.
To get around this, declare LoadIcon like the following in order to pass a parameter of the correct size (size of a pointer):
[DllImport("user32.dll", SetLastError=true)]
static extern IntPtr LoadIcon(IntPtr hInstance, IntPtr lpIconName);
public IntPtr LoadIcon(short id)
{
IntPtr i new IntPtr((int)id);
return LoadIcon(hInstance, i);
} If you need to overload LoadIcon to pass a string you can still do that. SendMessage , for example, is overloaded many different ways in the .NET BCL assemblies where it's used. So long as the parameter size is still the same (which is why you simply can't overload it and pass a short ) you're fine, so long as the right data is passed as that parameter.
Once you have the IntPtr return you can use Bitmap.FromHicon to load the icon into memory.
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:
Sorry about the vote of 1. I wasn't thinking and clicked the wrong link.
Don't worry!
Thanks, I got it working with P/Invoke. But I wish there were a a managed way of doing it.
Thanks!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Not to load an icon from a Win32 resource, no. Once you obtain a handle to the icon, however, you can use the method I mentioned in my first reply.
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]
|
|
|
|
|
Hello dear all
i want to display a notify message in windows application if user will get any new information then show one notify message in bottom right of window screen please help me how can i display a message
|
|
|
|
|
|
no basically i wnat to diaplay notify message like gmail notify do you have nay idea how we can show this type of alert
|
|
|
|
|
|
hello leppie
Thanks for solving my problem. yes i want to show exactally like that
|
|
|
|
|
Hi,
I was under the impression that if I wanted to center a MessageBox over any window, then I could use this class:
public class Win32Window : IWin32Window<br />
{<br />
private IntPtr m_hWnd;<br />
<br />
public Win32Window( System.Windows.Forms.Control ctrl )<br />
{<br />
m_hWnd = ctrl.Handle;<br />
}<br />
<br />
public System.IntPtr Handle<br />
{<br />
get<br />
{<br />
return m_hWnd;<br />
}<br />
}<br />
}
and then call the MessageBox like this:
Win32Window win = new Win32Window( this );<br />
MessageBox.Show( win, "Nú er gaman" );
but it doesn't work. Does anyone have a clue?
Best regards,
Daniel
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Whatever gave you that idea? From the documentation:<bockquote>The IWin32Window the message box will display in front of.That is, the IWin32Window is the owner of the MessageBox , but that doesn't mean the MessageBox will be centered over the owner.
Also, you don't need to implement IWin32Window . The Control class - even from which the Form class derives - implements IWin32Window . You just need to pass a Control reference. What you did was unnecessary.
In order to center a dialog over a particular control or form, you'll need to define your own class that extends Form with all the bells and whistles you need. Make sure you pass an owner Control and set Form.StartupPosition to FormStartupPosition.CenterParent .
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]
|
|
|
|
|
i don't know wheres the error but i'm tired of searching so i'll let u to explore it,
my xml file is like the following.
<code><xml version="1.0" encoding="utf-8">
<VoteData>
<Question id="0" name="do you believe in think tanks?">
<Choice choiceid="1" votes="0" name="Yes">
<Vote ip="192.168.1.1"></Vote>
</Choice>
<Choice choiceid="2" votes="0" name="No">
</Choice>
</Question>
</VoteData></code> i'm trying to use SelectNodes() method to select nodes,
<br />
XmlDocument VoteData = new XmlDocument();<br />
VoteData.Load(@"C:\VoteData.xml");<br />
XmlElement xElement = VoteData.DocumentElement;<br />
XmlNodeList xList = xElement.SelectNodes("/VoteData/Question[@id='0']");<br />
the problem that xList is always empty, no results !
thanx in advance
|
|
|
|
|
Try validating your XML in explorer/any other Xml aware application and you will see its badly formed.
You are missing ? marks in the xml declaration line... its should read:
< ? xml version="1.0" encoding="utf-8" ? >
|
|
|
|