|
Everything - even text files like XML - is still just an array of bytes. You must Encode before transmitting it across the wire. Even every web page, Web Service, etc. do that. What do you think the second clause of the Content-Type header (if there) or the Content-Encoding header is? That just the way it works.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is it possible to show a window form as the child of another window form in an SDI application? It was possible in VC++ 6.0 to show a dialog box as the child of another dialog box such as in property sheets. What I wanna know is that is this possible in C# also?
Its very urgent, any help will be greatly appreciated.
Thx in advance
Gurmeet S. Kochar If you believe in God, it's because of the Devil
My CodeProject Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
FormName.ShowDialog(this);
I'm not sure if this is what you are trying to achieve. If you want the child window to be contained within the frame of the parent window, I'd suggest either using mdi or putting your child window on a user control and adding it to your parent window's controls.
|
|
|
|
|
|
You can catch the moving of your form and if it goes out ow mainf orm adjuste it.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
The easiest way to do this, in my opinion, is to create a user control. This is basically a form without a border, at least from my understanding. Make your control the size of the client area of your parent window, and then add it to the controls of your parent window.
//This is in your variable declarations
private NameSpace.UserControl ChildControl;
//This is in your method that shows the control
ChildControl = new NameSpace.UserControl();
Controls.Add( ChildControl );
ChildControl.BringToFront();
ChildControl.Show();
Just make sure you have some way of closing your user control, because your frame is still the frame of your parent window, and will close the entire program. Put a button on your user control that will close it or something.
My advice on these is to not get carried away. Remember, you are only covering up the window with your user control, you aren't replacing it. I think this will work how you want it to work. Good luck!
|
|
|
|
|
|
I need help converting this code to C#, its taken from an Media Center SDK Doc.
HRESULT CreateSession([out,retval] IMediaStatusSession** MediaStatusSession);
Another question, since typedef doesnt exist in C# i converted the following code:
typedef SAFEARRAY(MEDIASTATUSPROPERTYTAG) MEDIASTATUSTAGARRAY;
typedef SAFEARRAY(VARIANT) MEDIASTATUSPROPARRAY;
HRESULT MediaStatusChange(
[in] MEDIASTATUSTAGARRAY Tags,
[in] MEDIASTATUSPROPARRAY Properties
);
to just:
void MediaStatusChange( [In, MarshalAs(UnmanagedType.SafeArray)] MEDIASTATUSPROPERTYTAG [] tags,
[In, MarshalAs(UnmanagedType.SafeArray)] MEDIASTATUSPROPERTY [] prop);
is this ok, or is there a way of converting the typedef?
modified 16-May-21 21:01pm.
|
|
|
|
|
this is for CreateSession, from the SDK doc.
IMediaStatusSink::CreateSession
Creates a media status session.
Parameters
MediaStatusSession
[out] Address of a variable that receives the IMediaStatusSession interface pointer.
Return Values
Return values are implemented by the component. The method should return S_OK.
Remarks
When the MSAS calls this method, your component must create an object that implements the IMediaStatusSession interface and place the interface pointer in the address specified by MediaStatusSession.
modified 16-May-21 21:01pm.
|
|
|
|
|
I should've read this message first.
Since CreateSession is a COM object method, you should just instead create a COM interop assembly, a.k.a. a RCW (Runtime Callable Wrapper). In VS.NET, just right-click on your project and select Add Reference. Click the COM tab and find the typelib. Double-click it to add it to the list and click OK. An interop assembly is created with all the interfaces, enums, parameters, etc. defined. All you have to do is use them and make sure that the interop assembly (it will get copied to your build directory) gets deployed as well with your library or application).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
If this is a method on a COM object, then you should create an interop assembly using tlbimp.exe, or add a COM reference to your project in VS.NET which does the same thing.
If this is a function exported by a DLL, you can use the following signature:
[DllImport("whatever.dll", PreserveSig=true)]
private static extern int CreateSession(ref IMediaStatusSession MediaStatusSession); IMediaStatusSession would be an interface that you would have declare that matches the native interface using the same order of methods (if inheritted from IUnknown or dual), dispatch IDs (if inheritted from IDispatch or dual), and signatures; or that is declared in an interop assembly created from the typelib.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have an array list with elements.
I am unable to access them through indexing.
Here ia my code:
int index = itemList.Count; Where "itemList" is my "ArrayList".
for (int i=0; i < index; i++)
{
string local = (string)itemList[i];
Console.WriteLine("Printing Array: {0} and I:{1}",(string)itemList[i], i);
}
My "local" string first gets assigned zero th element of "ArrayList", but when i=1,2,3,4 etc. my "local" string still has zero th element only.
I cannot use indexing this way. I have to use "MoveNext()" of Enumerator class to access?
Thanks & Regards,
Raj
|
|
|
|
|
Your code is not very readable - the < symbols have been interpreted as the start of HTML tags.
Please replace the < symbols with < so that when it is posted it will display correctly.
Thanks.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
Hi Sorry for messing up in Copy/paste.
Here is the code again.
int index = itemList.Count; Where "itemList" is my "ArrayList".
for (int i=0; i < index; i++)
{
string local = (string)itemList[i];
Console.WriteLine("Printing Array: {0} and I:{1}",(string)itemList[i], i);
}
Again my problem is
If there are 10 elements I am getting first element printed 10 times.
But If I use
System.Collections.IEnumerator myEnumerator = myCollection.GetEnumerator();
while ( myEnumerator.MoveNext() )
Console.Write( "\n{0}", myEnumerator.Current );
I am getting the correct output.
Thanks & Regards,
Raj
|
|
|
|
|
Out of curiousity. If all your elements are strings, why not use the System.Collections.Specialized.StringCollection class instead?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
Hey, try this:
ArrayList itemList = new ArrayList();<br />
itemList.Add("string goes here");
Then, you can access them like this:
for (int i=0; i < itemList.Count; i++)<br />
{<br />
Console.WriteLine("Printing Array: {0} and I:{1}", (string)itemList[i], i.ToString() );<br />
}
|
|
|
|
|
I tried that. Only first element (string)itemList[0] is getting printed. Suppose if count is 10, first element is getting printed 10 times.
If I use
System.Collections.IEnumerator myEnumerator = itemList.GetEnumerator();
while ( myEnumerator.MoveNext() )
{
Console.Write( "\n{0}", myEnumerator.Current );
}
I am getting correct output.
Thanks & Regards,
Raj
|
|
|
|
|
|
|
I suspect that you're getting confused somewhere along the line. Paste the exact code below into your project, run it, and report back:
<br />
ArrayList itemList = new ArrayList();<br />
<br />
itemList.Add("0");<br />
itemList.Add("1");<br />
itemList.Add("2");<br />
itemList.Add("3");<br />
itemList.Add("4");<br />
itemList.Add("5");<br />
itemList.Add("6");<br />
itemList.Add("7");<br />
itemList.Add("8");<br />
itemList.Add("9");<br />
<br />
int count = itemList.Count;<br />
for (int i=0; i < count; i++) {<br />
Console.WriteLine("Printing Array: {0} and I:{1}", itemList[i], i);<br />
} <br />
You're probably confused about assigning int variables. I imagine that you take a read of the Count property before you fill the ArrayList , yes? Well, that object is assigned by value, not by reference, because int is a value type. The part where you populate the array is the only piece missing in the information you gave us; notice the ensuing confusion? Next time, I'd include all the code that's probably part of the problem. I'm not being crusty, just trying to give helpful advice. Anyway, notice that above I read Count after filling the data. This is better on performance than reading Count every trip through the loop.
ArrayList is built specifically to replicate the semantics of accessing an array by index, and it uses an array internally to hold its data. It's probably silly to use an enumerator in your case. Enumerators were made so that all lists can be considered just to be implementations of IList .
Your explicit casts are unnecessary, but I left them in.
Regards,
Jeff Varszegi
|
|
|
|
|
How would you add a CheckBox column in a DataGrid?
Any help on this topic will be appreciated. Thanks in advance,
Jon
|
|
|
|
|
As I mentioned the other day, add a DataGridTableStyle to your DataGrid , which would have either DataGridTextBoxColumn s, DataGridBoolColumn s, or some custom DataGridColumnStyle . Make sure the DataGridTableStyle.MappingName matches-up with the table name (for data-binding to DataSet s or DataTable s) or class name (for binding against other IList or IListSource implementations).
Just see the documentation for the DataGridTableStyle in the Platform SDK for more information and an example, as well as the other classes and properties I mentioned above. It's really pretty simple, but you must make sure that your DataGridTableStyle.MappingName is correct or your table style doesn't get used.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You are a great help with giving me exactly the key words to point me in the right direction. Iv'e created the DataGridBoolColumns style, and made the MappingName match the table column i'm "binding" it to. How do I tell it to display a CheckBox? I don't understand how they add the CheckBox control inside the columns.
|
|
|
|
|
Like I said, you add a DataGridBoolColumn to your table style that you added with it's MappingName set to your boolean column. If you use values other than "True" or "False" for your data, then you need to set the DataGridBoolColumn 's TrueValue and FalseValue properties. Just see the DataGridBoolColumn documentation for an example.
Also, try playing around with this in the VS.NET DataGrid designer and then examine the code. It works best if you use a typed DataSet .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
DataGridTableStyle ts2 = new DataGridTableStyle();
ts2.MappingName = "library"; // name of the table
DataGridBoolColumn boolColLib = new DataGridBoolColumn();
boolColLib.MappingName = "super"; // name of the column
boolColLib.HeaderText = "Super";
boolColLib.TrueValue = "true";
boolColLib.FalseValue = "false";
boolColLib.AllowNull= false;
boolColLib.Width = 70;
ts2.GridColumnStyles.Add(boolColLib);
dtgAppserver.TableStyles.Add(ts2);
it should work like this
|
|
|
|