|
Hi All,
I am relatively new to c# and i am working in .NET 2003. I use very often a MessageBox, but sometimes it comes without a text on it, even if i have assigned a text to it (MessageBox.Show(stringVariable); ). The same happens to ComboBox and ListBox. They appear blank, although they are bound to the corresponding DataSource. Later (when the application is still running) appears the text suddenly. May be does anyone know the problem?
Very gratefull in advance,
Sailer
|
|
|
|
|
Your description offers almost no technical information that is necessary to help you. Please provide snippets of your code, including your data-binding code (just snippets though, please). It's probably that if you're getting data from the underlying data source your not taking the appropriate actions to get the right data. Debugging your application and stepping through your code is what you should do first. In Visual Studio, just open your project, set a breakpoint at the beginning of a method that uses MessageBox where the problem occurs, and hit F5 (Debug->Start Debugging).
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]
|
|
|
|
|
Well a messagebox takes at least 2 parameters the caller and message,
Therefore I would suggest you to use it like this:
MessageBox.Show(this,StringVariable);
For the combobox & listbox, I would suggest you to loop through the datasource and insert an item every time! In this case, you can debug and it will be 1000% sure the items will be added!
Regards
GaMBiT---> aND ReVeNGe WiLL Be
|
|
|
|
|
Some people say that C# can't work with custom C++ interfaces. But at least I can see them in C# Object Browser.
Does anybody know the exact situation???
If C# does support custom interfaces how such type incompatibilities like byte[] and string can be handled???
Are there any botle necks???
Could it be faster using custom interfaces in C# instead of dispatch???
Vad
|
|
|
|
|
What do you mean by custom interfaces? C# classes can most definitely implement interfaces declared in C# that interop with native interfaces. I do it all the time, as COM interop is one of my fortés. You should start by reading Exposing .NET Framework Components to COM[^], since implementing a COM interface - if that is what you mean - would only make sense if you were trying to host your .NET Framework component in a COM client.
Strings and byte[] also marshal correctly and quite easily. Read Marshaling Data with COM Interop[^].
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]
|
|
|
|
|
By custom interfaces I mean those COM object, designed for C++ usage and inherited from IUknown interface, and not from IDispatch. Such COM objects do not contain definitions for Automation types, that clients such as VB can simply use.
Actually, my problem is: I have 2 COM libraries, implemented as set of Dispatch objects for automation and set of Custom objects for C++ usage. And I'd like to write my own DLL based on on of those sets. The main question is: what language should I use??? I tryed C# with Dispatch objects set and found it rather slow. So, maybe I can use C# and set of custom interfaces, or shall I switch to C++.NET???
|
|
|
|
|
What interface from which you derive doesn't dictate what types you pass as parameters. Even if you don't inherit from IDispatch (in managed code, using [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] or ComInterfaceType.InterfaceIsDual ) you can stil, for example, pass or return a SAFEARRAY .
Be suer to read those links I gave you in my first reply.
What you should be doing is using dual class interfaces, which expose interfaces for both VTBL binding (IUnknown ) and automation. Even automation-only interfaces can be used by C++, but it can be a pain.
See the documentation for the ComInterfaceType.InterfaceIsDual member in the .NET Framework SDK for more information.
As far as performance, keep in mind that not only are you marshaling to different components you're marshaling across native and managed boundaries. The Common Language Runtime (CLR) marshals data for you in most cases, and it can take time depending on what the data is. C++.NET won't solve things either, since you'll be compiling managed code which will also target the CLR. In fact, until C++ .NET 2.0 (Managed C++ 2.0, as it's more commonly called) performance even within MC++ can be bad because of data being marshaled from native to managed within the same DLL. It really just depends on what you're doing.
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,
I am a beginner in C# and I have problem with reading and writing text file with code page WIN 125O or ISO 8859-2 (Czech)
Please how I must use StreamReader and StreamWriter and how I set codepage for this one.
Thank you for any answer
Libor Matejka
|
|
|
|
|
Hi
i have a treeView that is collection of Person object(each person has ID and Name ).
this treeView has infinit depth because a person can be child of other person.
i want to trace the treeView and check IDs but i dont what to do?
|
|
|
|
|
You can recursively traverse the tree, starting from the root(s). Something like
<br />
foreach(Node root in treeView.Nodes)<br />
{<br />
CheckID(root);<br />
}<br />
<br />
private void CheckID(TreeNode root)<br />
{<br />
Console.WriteLine((Person)root.Tag).ID);<br />
foreach(Node element in root.Nodes)<br />
{<br />
CheckID(element);<br />
}<br />
}<br />
Regards
Senthil
My Blog
|
|
|
|
|
How Can i change a folder's icon using C# as whn i share a folder its icon changes
|
|
|
|
|
If you just want to change the image of an item in the tree view, change the ImageIndex (and SelectedImageIndex ) properties to the index of the desired image inside the imagelist.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hello
I have a problem that I can't find any solution to. I have an arraylist of objects that I want to show in a datagrid and that works just fine. The problem is when the objects themselves has an internal property that is an arraylist, then the datagrid will show the "+" sign att each row. I want the datagrid to show only the "parent" rows without drilldown features.
For example
public class MyStuff
{
string stuff;
public MyStuff()
{}
public MyStuff(string NewValue)
{
stuff = NewValue;
}
public Stuff
{
get{return stuff;}
set{stuff = value;}
}
}
arraylist MyList = new arraylist;
for (int iI = 0, ii <10, ii++)
mylist.add(new MyStuff(ii.tostring()))
datgrid1.datasource = MyList
works just fine, but
public class MySecondStuff
{
string stuff;
public MySecondStuff(string NewValue)
{
stuff = NewValue;
}
public Stuff
{
get{return stuff;}
set{stuff = value;}
}
}
public class MyStuff
{
string stuff;
arraylist arList = new arraylist();
public MyStuff(string NewValue)
{
stuff = NewValue;
for (int iI = 0, ii <10, ii++)
arList.add(new MySecondStuff(ii.tostring()))
}
public Stuff
{
get{return stuff;}
set{stuff = value;}
}
}
arraylist MyList = new arraylist;
for (int iI = 0, ii <10, ii++)
mylist.add(new MyStuff(ii.tostring()))
datgrid1.datasource = MyList
Will show the parent MyStuff correctly in the datagrid but each row will have the "+" sign next to it and allow the user to see the MySecondStuff class under it. Can anyone please say how I can remove the "+" sign when working with arraylist or collections in the datagrid?
I now the code above doesnt work, just wrote it to explain how the classes are built when they are viewd in a datagrid.
Best regards
/Marcus
|
|
|
|
|
Hi there,
I'm relatively new to C#. I am making a class library(DLL) firing custom events. I want to have another windows application (in C#) that handles such events. I'm creating delegates and declaring events in the dll, but when I create an instance of dll and attach an event handler to handle a particular custom event, an exception saying that there is no instance for event handler is raised. I tried handling the events from the dll, with an empty method, and yet attaching a handler on the calling application, the result is that nothing happens.
Do you have any clues to help out please?
ThankS
GaMBiT---> aND ReVeNGe WiLL Be
|
|
|
|
|
I suggest you to create an event of your delegate type in the application, where you suppose consume this event.
eg: This is the dll defanision.
using System;<br />
<br />
namespace ClassLibrary1<br />
{<br />
public delegate void Me();<br />
public class Class1<br />
{<br />
public Class1()<br />
{<br />
}<br />
}<br />
}
Below one is the application code block , where i am going to consume this event.
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
private event ClassLibrary1.Delegate Evt;<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
this.Evt+=new ClassLibrary1.Me(Form1_Evt);<br />
this.Evt();<br />
}<br />
private void Form1_Evt()<br />
{<br />
MessageBox.Show("afasfasf");<br />
}
Sreejith Nair
[ My Articles ]
|
|
|
|
|
thanks man!
great help!
GaMBiT---> aND ReVeNGe WiLL Be
|
|
|
|
|
Thanks...I managed to solve my problem...
I had a misplaced code problem.
Sorry and Thanks!;P
GaMBiT---> aND ReVeNGe WiLL Be
|
|
|
|
|
Hi !
iam doing a remoting application is c#. the server is a singlecall object run using remoting.configure
xml config file. there is only one client but a group of servers hosting these singlecall objects
. i make invocations by using remoteobject.getactivator method at a very high frequency to get bit map data. when the server machine is running windows 2000 professional the performance is decent but for windows xp pro the performance is very bad. the system is very slow at getting method results. any idea what could be happening. i checked
three windows xp pro machines and as many windows 2000 pro machines. the performance is consistently bad and good respectively.
any help would be great.
thanks.
|
|
|
|
|
i trying to wirte a code to disalbe toolbar start , and run mstsc40.exe
using System.Diagnostics;
i can't use Process object !!!
|
|
|
|
|
Your question would be much better handled in the Embedded/Mobile Forum[^]. It has nothing to do with C#, but rather functionality of the target platform.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello
I am drawing text by using Graphics.DrawString
I need to rotate it.
this: StringFormatFlags.DirectionVertical; rotate text 90degrees clockwise.
However I need rotate text 90deg. counter-clockwise. How I will do it?
heartfelt thanks for help.
Peter
|
|
|
|
|
I am trying to load data from a as400 db into a datatable, but i get the following error:
OleDbDataAdapter internal error: invalid rowset accessor: Ordinal=5 Status=UNSUPPORTEDCONVERSION.
Can anyone tell me how to fix this?
|
|
|
|
|
this thread talks about your problem - hope it can help - cause I can't
http://www.dotnet247.com/247reference/msgs/43/219462.aspx
-spif2001
|
|
|
|
|
hello i have 2 classes one class has a function that takes the second class as a ref argument however i want to call this function from within the second class but the compiler will not let me using, this, is there any way around doing without making the function take a non ref argument?
|
|
|
|
|
You can't pass 'this' a ref argument because it is a value, not a variable. This will satisfy the compiler
<br />
A a = this;<br />
new B().SomeFunc(ref a);<br />
I don't know if that is what you want though..
Regards
Senthil
My Blog
|
|
|
|