|
So, Is something like this?
[WebMethod]
[XmlInclude(typeof(CTestClass))]
[XmlIncludeAttribute(typeof(CTestClass))]
public bool GoObject(object obj)
{
if(obj is CTestClass)
{
return true;
}
return true;
}
Raphael Amorim Dantas Leite
VC++, Java and C# programmer. Win32 and PocketPC enviroments
|
|
|
|
|
You actually have the XmlIncludeAttribute specified twice! Remember that languages like C#, VB.NET, and MC++ don't require the "Attribute" suffix, though some languages might (it depends on the compiler). Simply:
[WebMethod]
[XmlInclude(typeof(CTestClass))]
public bool GetObject(object obj)
{
if (obj is CTestClass) return true;
return true;
}
And make sure that the assembly in which CTestClass is defined is referenced as a dependent assembly (or in the Web Service assembly itself, although this doesn't make any sense since the client can't use the type (even if retyped, since a Type is defined by its namespace, class name, assembly name, and public key token).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello, has anyone ever created a MIME filter before (c# or otherwise)?
I tried to make a mime filter for a content-type that I invented: "text/myml", and when I test it, my filter's Start() method get's called, but then nothing else happens. The behavior in the browser is that it just hangs until I click the stop button. Although, when I click the stop button, IE calls my mime filter's Abort and Terminate methods.
Is there something special my MIME filter has to do in the Start method? All I have it doing right now is store m_Sink and m_pIncomingProt.
Also when Start() is called, dwReserved.pProtocol comes in null. I don't know why but that seems like a bad thing?
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Do you have documentation source for this? I need to do something similar, and I assumed that it would require writing a COM server...
Arun
|
|
|
|
|
It does, and I haven't had much success doing so. You need to look into the IInternetProtocol interface and its related interface. You basically have to recreate a lot of that functionality in .NET. By the time you're done, you may as well have done it in C++ because of the amount of work.
I was working on a library for it (abstract class and stuff like that), but there's a lot of hang-ups because interface methods don't always interop using 1-to-1 parameter mapping. For instance, the IClassFactory.CreateInstance method is only supposed to take 2 methods (while the return type is still void) instead of 3. Just weird stuff like that.
If you want, you could create forward declarations of these in an IDL file, compile the IDL file using the MIDL compiler, then generate an interop assembly using tlbimp.exe. It works to generate the interfaces, structs, and enums, but it's very messy and doesn't always provide what you need. For instance, it always creates methods that return void , when some of those protocol methods must return an HRESULT (int or uint is good in .NET) in order to work correctly, since different return values tell the client to do different things. This becomes a big problem when generating the interop assembly automatically.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I would like to be able to accept phone numbers in various formats:
800-555-1212
800.555.1212
(800) 555-1212
(800)555-1212
and then format it to this:
800-555-1212
i created a function which strips out characters: ()-<space>
so now my number is: 8005551212
but how can i put the "-" back in there to make it 800-555-1212 ?
thanks in advance!
|
|
|
|
|
Check out the String.Insert() method....
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Use String.Format().
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I have a panel with scrollbars, and now I want to be able to control the scrollbars with up-down-right-left and pgdown/pgup keys. So I've added key listeners, like below:
.
.
else if(ke.KeyCode == Keys.Left)
{
AutoScrollPosition = new Point(this.AutoScrollPosition.X + 10, 0)
}
else if(ke.KeyCode == Keys.Right)
{
AutoScrollPosition = new Point(this.AutoScrollPosition.X - 10, 0)
}
.
.
now the first time i press the 'right' key it will jump 10, but when I press the same key again,
the position will be reset!!!! why why why.
I check the autoscroll position before i press 'Right' and it's 0. afterwards it's -10.
the before i press it again it's -10 also. But when i press it yet again, it's back to 0 ...??
can anyone please tell my why (-10) - (10) equals 0 ??
|
|
|
|
|
Have you tried this?
else if(ke.KeyCode == Keys.Left)<br />
{<br />
AutoScrollPosition.X += 10;<br />
}<br />
else if(ke.KeyCode == Keys.Right)<br />
{<br />
AutoScrollPosition.X -= 10)<br />
}
|
|
|
|
|
Does anyone know how i can use the GetCursorInfo API in C#? I'd like to know the dllimport and an example code.
Click here to view the GetCursorInfo API.
|
|
|
|
|
You have to recreate the sturct and ref that in your P/Invoked statement:
public struct CursorInfo
{
public int size;
public int flags;
IntPtr cursor;
System.Drawing.Point point;
}
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool GetCursorInfo(ref CursorInfo info);
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for the quick reply but i'd like to know how to use it too. I'd like to know how to get the cursor image (or icon) using GetCursorInfo.
|
|
|
|
|
It's all in the documentation on MSDN. I suggest you read it. There's examples, too. Always consult the docs for questions like this, when asking "what is X" or "how does Y" work, otherwise you're just grabbing at straws and guessing, which doesn't build any skills. I don't mean to sound rude, but researching is half the development battle, and these questions are exactly what the Windows API functions, .NET class library, and other documentation is for. Besides, it'd be a waste of time to essentially copy and paste the topic you want. Just type GetCursorInfo in the index and you've got what you want. As far as managed code goes, however, read on...
If all you're trying to do is read-in a cursor image, then you need to look at the Cursor class. It's better to use managed code than to start needlessly P/Invoking stuff from the Win32 API. It has everything you apparently need to read-in a cursor and display it (either as the mouse cursor or a bitmap (with some fiddling) such as a preview pic).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I'm aware of that. The thing is, i don't understand how to use GetCursorInfo. I just need some help in getting the cursor image which is vital for my program, that's all. Anyway, i'll try reading again.
|
|
|
|
|
If all you want is the cursor image to draw on a surface or something, the Cursor class documentation provides all the information you need - no P/Invoke is necessary. As I said, use managed code whenever possible.
See Cursor.Current and Cursor.Draw() :
Cursor c = Cursor.Current;
Graphics g = this.myControl.CreateGraphics();
c.Draw(g, this.myControl.Bounds);
g.Dispose();
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
No, i just need to know the name of the cursor whether it is a normal cursor showing or wait cursor showing - system-wide (not just within the current form). From my understanding, if you use Cursor.Current, you can only get the name of the cursor that is showing within the form. If the cursor moves outside of the form, the name of the cursor will not be changed.
|
|
|
|
|
As I stated before, recreate the structure and P/Invoke the interface:
[StructLayout(LayoutKind.Sequential)]
public struct CursorInfo
{
public int Size;
public int Flags;
public IntPtr Handle;
public Point Position;
}
public class NativeMethods
{
[DllImport("user32.dll")]
public static extern bool GetCursorInfo(out CursorInfo info);
}
Based on this code and the docs for GetCursorInfo, calling it should be no problem:
CursorInfo info = new CursorInfo();
info.Size = Marshal.SizeOf(info.GetType());
if (NativeMethods.GetCursorInfo(out info))
{
Cursor c = new Cursor(info.Handle);
}
I've tested this and it does work fine.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks a lot. That did the trick.
|
|
|
|
|
Let assume I have a datagrid that contains the following data
ID VAL1 VAL2 VAL3
1 abc def ghi
2 jkl mno pqr
3 stu vwx yz1
4 234 567 890
On the same form I also have a list box with the following values :
2
4
Using the 'SelectIndexChanged" event I want to highlight the relevant ID in the data grid. So lets say I click on '4' the following line in the datagrid would be selected :
4 234 567 890
|
|
|
|
|
I think you can use the below function of datagrid
DataGrid.Select(rowIndex)
I'm not sure about how you'd get the rowindex of that particular id.
- Kannan
|
|
|
|
|
Thats about as far as I got with it.
I just couldnt find a way to get the rowIndex for the selected value in the listbox
|
|
|
|
|
There's many ways. If your DataGrid is not sorted and hasn't been sorted, you can use a myriad of method to get the index of the row in the data source, then use that in DataGrid.Select() . If you knew the index of the column for the key, you could use the DataGrid.Item and loop through rows (using for instead of foreach so you can get the index from, say, i 's current value when you find what you're looking for). It's all in the documentation. Just spend a little time researching what's available before jumping into it. You can use members on DataGrid , the DataSet , a DataRow or DataRowView , or even use a strongly-typed DataSet which provides you with additional options.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Well after some playing I came up with this piece of rather convoluted code, but it does what I need. Here it is just incase anybody else is looking for something similar in the future :
CurrencyManager cm = (CurrencyManager)dgData.BindingContext[dgData.DataSource];
for (int i = 0; i < cm.Count; i++)
{
DataRowView drv = (DataRowView)cm.List[i];
if (item == drv.Row["CDBNO"].ToString())
{
dgData.CurrentRowIndex = i;
dgData.Select(i);
}
}
|
|
|
|
|
A little tip: don't use the DataRow.Item[String] syntax - it performs many lookups and doesn't cache squat! Each time you use it (so in your case, with each loop) it must enumerate all the columns, do case-insensitive string comparisons with each column till it finds the right one, get the index and then does some stuff with column versions before giving you what you want. I suggest you get the column index or DataColumn upfront before starting your loop and using that index or DataColumn instance instead of a string. If done throughout your code, you most likely will notice a performance increase.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|