|
This has been covered many times in the past - including a discussion recently. Please search the C# forum comments for links and information. The is a Search Comments link at the top of the messages view.
-----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've setup a browser in an application similar to what has been explained in this article, when I browse around to one or two different HTML files and then go to a powerpoint document things work fine. If I check out more than one or two HTML files and then go to a powerpoint document, I'm able to click and advance one slide, but further mouse clicks do nothing, not even right clicking. At this point I'm able to use the mouse wheel or the scrollbar on the browser to advance, then everything works fine again.
I've been searching on msdn for any info on using powerpoint within the browser control but haven't been able to find anything yet.
|
|
|
|
|
My web calendar control is correctly populating each calendar cell with the course and time as programmed. Problem: it's creating twins! Each listing is created twice. Stepping through the code revealed that each calendar day is being rendered twice. What do I need to do to nonduplicated entries?
Code Follows:
protected void C1DayRender(object sender, DayRenderEventArgs e)
{
if(courseTable.Rows.Count>0)
{
CalendarDay d = ((DayRenderEventArgs)e).Day;
TableCell c = ((DayRenderEventArgs)e).Cell;
DateTime tempDate;
foreach(DataRow dr in courseTable.Rows)
{
tempDate = (DateTime)dr["sDate"];
if(tempDate.ToShortDateString() == d.Date.ToShortDateString())
{
string s1 = " " + dr["CourseName"] + " " + tempDate.ToShortTimeString();
c.Controls.Add(new LiteralControl(hypRegister.Text = s1));
}
}
}
}
I'm on a crunch deadline, and I think I am just missing a piece of code here to get this function to move to the next date after grabbing any matches in the container.
Thanks, Sally Lay
Sally Lay
|
|
|
|
|
Solved the problem. This calendar does more than reflect a schedule; it is also a registration tool. Removing the "this.Calendar1 += new Calendar1.DayRender;" line in the generated web designer form code made each day render itself only once. Thanks, Sally
Sally Lay
|
|
|
|
|
I have a function that needs to accept a string and append it to another string. I initially implemented it like this:
private String big = "";
...
private void OnIncoming( String small )
{
big += small;
big += "\r\n";
} However this seems to be extremely inefficient. Receiving about 300K of text (which happens to come from the net) in small amounts takes about 1 minute. However, if I simply comment out the contents of OnIncoming (the two += lines) it takes about 5 seconds. So it appears the string concatenation is causing the problem.
How can I improve this? I need to take a bunch of little strings (one at a time), and concatenate them into a larger string. Any suggestions as to what would be the most efficient way to do this in C#?
Thanks in advance for any suggestions, ideas, or assistance!
|
|
|
|
|
You should use String.Concat for up to 4 string parameters, String.Format if you can format your string, or - which can be used for all - a StringBuilder (which String.Format uses internally).
Also, keep in mind that string are immutable while the StringBuilder is not (meaning it can actually grow). When you concatenate strings, the CLR must get the length of both strings, create a new string of the total length, then copy each character from both strings. You're right - it is very inefficient. The methods and class above will help you (and are nice for formatting and what-not, too).
-----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-----
|
|
|
|
|
Everyone, I'm hoping to call an unmanaged C/C++ function within a DLL directly from a C# class without having to bother with a managedC++ class as proxy. However, the DLL function includes the MFC CString in its prototype, so I'm thinking that perhaps I'm going to need to.
[DllImport( @"C:\Program Files\MyCompany\MyDLL.dll", CharSet = CharSet.Ansi)]
public static extern IntPtr MyFunction(CString arg1, CString arg2);
I understand that the InteropServices will likely be involved, and I'm about to do
my homework so see what needs to be done, but if anyone knows the answers, then
feel free to fill me in.
Best,
Jerry
|
|
|
|
|
Correct me if I'm wrong, but aren't CString 's Unicode when UNICODE is defined (for applicable OS's)? If so, you should be using CharSet.Auto .
Also, remember that CStr is a wrapper, where the string is actually stored in m_str (or something like that), so you'd probably have to create a related structure and marshal to that struct. In that case, place the CharSet=CharSet.Auto in the StructLayoutAttribute for the struct.
I wish I could tell you more, but it's been a while since I worked with MFC and, believe it or not, CString doesn't show up in the class list!
-----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-----
|
|
|
|
|
Is it possible to add a button to Internet Explorer's main toolbar (next to the "History"-button)?
Andreas Philipson
|
|
|
|
|
Not right next to the History button, no, but you can find information about adding buttons after the separator to the right of the History button here: Adding Toolbar Buttons[^].
Also, this isn't really the forum for this question.
-----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-----
|
|
|
|
|
Is there a way that I can create a copy of a textbox out of a TabPage and insert it into another TabPage. The way I've been trying is to add() the TextBox to the second TabPage but this removes it from the first.
I would really like for it to call the same TextChanged() function.
Any suggestions?
Thanks,
Matt
|
|
|
|
|
Point both textboxes at the same TextChanged handler
|
|
|
|
|
Mark's idea is a good one. I just wanted to add that a control can only have one parent. This is pretty much universal and goes down to the Windows Common Controls that pretty much each control in System.Windows.Forms wraps.
-----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 have a datagrid and I want the data displayed and allow the user to select a record. But I don't want the blank last row displayed. I don't want them to be able to enter new data in this datagrid. This one is for selecting a record only.
Thanks for any help
|
|
|
|
|
append in your init :
MyDataGrid.ReadOnly = true;
|
|
|
|
|
Sorry, I goofed on the problem description. I want to be able to type into the existing populated grid rows (to update them) but not have the blank new record entry at the bottom
Thanks for your help
|
|
|
|
|
Hi, i'd also be interested in this, so if anybody knows...
|
|
|
|
|
Hello!
I'm having a bit of difficulty with an LDIF file that I need to parse for a piece of communications software I'm writing. The application will run on a non-networked machine in the field on Windows 2K. I had hoped to use MS's ADAM, but that requires Windows XP or 2003 Server to run. I don't need a directory per se, just to be able to parse the contents of the ldif file exported from the server into a tree- I know how to do this when connecting to a directory server, but am having difficulty with just a flat file. Is there a way to make the .NET DirectoryServices object "connect" to a file instead of to a server? I really, really don't want to have to write a parser for this beast.
Thanks!
Melissa
|
|
|
|
|
I am starting to construct an experiment that will eventually contain evolutionary objects that follow genetic algorithmic coding.
The simple tasks always seem to be the hardest.
Each object is on an independant thread.
Each object of its' own type must be able to communicate with the others.
Each object must be able to communicate frequently with either specific entities (ie. 'neighbors') or all members of the group (but not via broadcast).
I know I need to do point-to-point but I'm not really sure of the best approach. The resulting web of connections between n number of entities could easily swamp a system.
A thought is that each entity listen on a specific port, can talk to only the neighboring ports, and a 'tell all' command would be telegraphed from entity to entity until the message has made it around to the initiator. I'm just not sure where to start on constructing this.
I've looked at the SDK for TCPListeners and TCPClients and it is a good start, but if anyone has experience with a p-t-p connection process I am all ears.
Thanks
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
You should take a look at .NET Remoting. You get a lot more flexibility, and you could devise a system where the remoting server (could even be in your same process) keeps track of registered clients and sends commands to the right clients based on Type information (judging by your description) and remote method calls. There is some more complexity involved than simple socket programming, but you get a LOT more flexibility because you can chain message handlers (objects that act on message data or even change that message data) and do many other things (like even compressing the message data using a compression sync handler to and from a remote object).
There are several good articles here on CP, and you should get a book like MS Press's ".NET Remoting", which is a good beginner and intermediate book about .NET Remoting.
This way, your threads don't have to keep references to each other and can instead use a broker system through Remoting. You could also broker objects using ContextBoundObject classes, or even with a normal class, but using either remoting or a ContextBoundObject lets you capture messages (for method calls, return messages, etc.) before they are received or sent by the client or server.
-----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-----
|
|
|
|
|
Heath,
Believe me, I thought about doing that since it is so easy to do. But that ties them down to the server. The design concept behind the evolving code is for each construct to be an independant, evolving entity with evolution occuring by the 'swarm' through their own network. Each entity is eventually implemented with genetic algorithms to implement the evolution. I saw a hint of something somewhere that suggested a neural network, but I don't know if I want to construct one from scratch in .NET. (could be an interesting undertaking though)
So it will be more of a peer-to-peer communication without a server go-between. (I can always hold that remoting server as a First Build approach, but then I have to address this sooner or later.) I just have to figure out the best approach to take to start the networking --> and that is what I'm trying to figure out.
Thanks for the input!
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
You've got a point, but remoting doesn't necessary have to be a client-server approach, each object would act as both - just communicating with each other. It might not work for your situation, though.
-----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-----
|
|
|
|
|
Heath,
The more I thought about this over the weekend, the more I liked it! Each entity could spawn a Communicator component with a fixed message format. For the initial behaviour test, we can make it a simple neural ring where each has a known neighbor (port number) and the last in the chain has the first entity as its' neighbor.
They can pass a standard, serializable message format with a header similar to the TCP packet header. So there is an indicator of the transmitter, receiver (specific or all), and the packet of data to be consumed. Once the packet travels the entire ring back to the originator, the originator communicator logic knows that it is his own and brings the communication circle to an end. (in the case of a non-directed message packet) And if the packet is directed then the movement of the packet stops at that point.
Better yet, we were planning on deploying the ant genetic algorithm in these guys once we knew we could monitor them, and this communication pattern matches the way ants communicate at a basic level. This also positions the entities to be started up independant of "Mom" which is our monitoring program.
Once the behaviour test works, then we incorporate the Ant genetics with swarming (the swarm behavior comes into play when the anthill is attacked). We can provide a digital representation of how the current communication pattern exists, then have the Ant Genetics determine the most efficient path for each to communicate with each other. (a similar method was deployed at a telecom company to determine the shortest route through the phone network for point-to-point) The ant genetic algorithms basically use the methods that the ants use to determine the path from the food they find for a shortest return trip to the anthill. Once they have the formula worked out we can deploy that at startup.
Thanks,
Michael
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
I've been playing with the idea of multicasting .NET objects, by first serialising them to a Memory stream, and then well, multicasting them on a network for those that want to subscribe and listen.
This code snipet shows the kind of thing.
http://www.dotnetextreme.com/articles/multicasting.asp[^]
It would probably be best to deserilize to an Object, and then cast to the object type that is needed.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
Giles,
This looks interesting as a possibility. But I'm more inclined to implement .NET remoting for the first try. Remoting layers will handle the message packet serialization themselves. But I will keep this one on the back burner.
Michael
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|