|
Say i had a main class like..
class MainClass : Form
and i had another class
class Control
can I add a function to an event handler through the Control class to the mainclass? if not is there a way around this? any solutions will be appreciated thx for the help.
IM PROUD TO BE A GMAIL;
|
|
|
|
|
If I am reading you correctly, then the answer is yes.
((MainClass) this.ParentForm).MyEvent += new ...
|
|
|
|
|
Hi everybody.
Can somebody direct me to a correct algorithm to solve the sort problem of the following array of data:
ServerWeb.*
ServerWebSomething1
ServerWebSomething2
ServerWeb3
ApplicationServer1
App.*
ApplicationServer2
should be sorted as this:
ApplicationServer1
ApplicationServer2
App.*
ServerWebSomething1
ServerWebSomething2
ServerWeb3
ServerWeb.*
The point is that the data is first sorted alphabetically, and then withing the similar types of data I need to get the data with more specific to the top and those less specific to the bottom.
For instance, as ServerWeb.* covers all servers that starts with the "ServerWeb" it is the least distinctive, while ServerWebSomething1 is the most distinctive in that subgroup.
This just puzzles me, I would appreciate any algorithm in any language if C# example is not available.
Thanks.
|
|
|
|
|
What you need to do is to define a way to compare two of the values. If you just do that, you can then use any sorting algorithm. You can even make a class that implements ICompareable and use the SortedList class to sort them.
What information does the names contain? How do you separate the different parts of information? Why is, for an example, "ServerWebSomething1" more distinctive than "ServerWeb3"?
---
b { font-weight: normal; }
|
|
|
|
|
I am having some problems adding dynamic MenuItems to a context menu in a C# Windows application. Look at the pasted code below. Click the Add Item button a couple times, then right click anywhere in the checked list box. List Items should expand with a list of all the items in the checked list box.
Now, click the button a couple more times and notice the change on the right-click context menu. List Items no longer expands!
I've also tried:
Clearing ListItems.MenuItems collection and re-adding new MenuItems on Popup
A static list of MenuItems added to ListItems.MenuItems in InitializeComponent, set visible or not depending on the number of items in the check box
Any ideas?
Compile the code with: csc /target:winexe MenuTest.cs
////////////////////////////////////////////////
// Begin Pasted Code Here
///////////////////////////////////////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
public class MenuTest : System.Windows.Forms.Form
{
private System.Windows.Forms.Button AddItem;
private System.Windows.Forms.ContextMenu DynamicMenu;
private System.Windows.Forms.CheckedListBox ListBox;
private int ListItemCount = 0;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem ListItems;
private System.ComponentModel.Container components = null;
public MenuTest()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.ListBox = new System.Windows.Forms.CheckedListBox();
this.AddItem = new System.Windows.Forms.Button();
this.DynamicMenu = new System.Windows.Forms.ContextMenu();
this.ListItems = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
this.ListBox.Location = new System.Drawing.Point(8, 32);
this.ListBox.Name = "ListBox";
this.ListBox.Size = new System.Drawing.Size(120, 94);
this.ListBox.TabIndex = 0;
this.ListBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ListBox_MouseDown);
this.AddItem.Location = new System.Drawing.Point(32, 152);
this.AddItem.Name = "AddItem";
this.AddItem.TabIndex = 1;
this.AddItem.Text = "Add Item";
this.AddItem.Click += new System.EventHandler(this.AddItem_Click);
this.DynamicMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.ListItems});
this.DynamicMenu.Popup += new System.EventHandler(this.DynamicMenu_Popup);
this.ListItems.Index = 0;
this.ListItems.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem3});
this.ListItems.Text = "List Items";
this.menuItem2.Index = 0;
this.menuItem2.Text = "Here Is A List";
this.menuItem3.Index = 1;
this.menuItem3.Text = "-";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(136, 189);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.AddItem,
this.ListBox});
this.Name = "MenuTest";
this.Text = "MenuTest";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new MenuTest());
}
private void AddItem_Click(object sender, System.EventArgs e)
{
this.ListItemCount++;
this.ListBox.Items.Add( "item" + ListItemCount.ToString() );
}
private void ListBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right )
{
System.Drawing.Point pt = new Point( e.X + 10 , e.Y + 25 );
this.DynamicMenu.Show( this, pt );
}
}
private void DynamicMenu_Popup(object sender, System.EventArgs e)
{
foreach( object o in this.ListBox.Items )
{
this.ListItems.MenuItems.Add( o.ToString() );
}
}
}
|
|
|
|
|
The problem is that you are not creating an instance of the menuitems. Use an ArrayList to store each new menu item. Also, it's best to add the menuitems in your method "AddItem_Click". So modify the AddItem_Click as follows:
<br />
ArrayList arr = new ArrayList(); <br />
private void AddItem_Click(object sender, System.EventArgs e)<br />
{<br />
this.ListItemCount++;<br />
this.ListBox.Items.Add( "item" + ListItemCount.ToString() );<br />
<br />
MenuItem mi = new MenuItem("item"+ListItemCount.ToString());<br />
arr.Add(mi);<br />
this.ListItems.MenuItems.Add(mi);<br />
}<br />
>/code>
|
|
|
|
|
I would like to send a string from one windows application to another.
Would anyone know how to do this using the SendMessage WinAPI function?
My attempts have failed so far.
|
|
|
|
|
Don't do it using the SendMessage method; that is for window messages.
Do you have access to the source code of both applications? If so, use .NET remoting or web services to pass a string.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Conversation With a Muslim
Judah Himango
|
|
|
|
|
Thank you for the response.
Yes I have the source code for both apps. At present, the apps are just for test purposes. Trying to determine the best method for application communication.
I've had a quick look at remoting. I was unable to figure out how a remoting object is able to communicate / attach itself to an application?
The information I am trying to send across is to inform an allow the application to perform some work.
|
|
|
|
|
I'm programming a C# application and I have one thread making one operation.
This threads is called by a method.
When I use this method from the current Application, by means of a Button it works properly. But if I call this method from another thread the method works only if this thread still alive.
I guess that in the 1st case the threads parent is the application thread but in the second case the parent is the other thread.
I can see it because I generate a Form with this method/thread and it disapears suddenly when I use a thread for call it.
Some help??
PD: Sorry for my English
|
|
|
|
|
You'd need to state the problem more clearly.
From your description, it looks like you're trying to launch a Form from within the thread. Did you use Form.Show or Form.ShowDialog ? I suspect you used Form.Show , that's the reason it worked when invoked from a button. A modeless dialog requires a message pump[^] to be running on the calling thread. When you create one with a button click, it'll use that threads' message pump (which is what processed your message). When you create one in your own thread, you have to run the message pump yourself, like this
Form form = new Form();
Application.Run(form);
in your thread.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I'm sorry but this does not works.
I cannot use the method ShowDialog() because I need the Form behaviour and use Aplication.Run(form1) throws a Exception.
...
Maybe I missunderstand your directions, but I think that there will be another solution using some thread properties.
Thanks for your advice.
|
|
|
|
|
Hi,
Is it possible in datagrid to assign a hidden tag for each row identify the AutoNumber ID from the database instead of displaying it as a column?
Best Regards,
Jassim Rahma
|
|
|
|
|
You can change that cell to be not visible in the DataItemBound method for your datagrid. Something like this....
<br />
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)<br />
{<br />
e.Item.Cells[0].Visible = false;<br />
}<br />
Steve Maier, MCSD MCAD
|
|
|
|
|
I'm no longer using DataGrid because it was lacking so many features I needed such as setting row/cell keys conveniently. I'm currently using iGrid.NET from www.10tec.com. I'm very happy with it so far. Using this grid, I can easily set the row key like this: iGrid.Rows[row].Key = rowKey;
Glenn
|
|
|
|
|
Thanks for your reply..
what about data resfresh?
because using datagrid I have to clear the dataset and fill it again which takes time specially on a network.
Best Regards,
Jassim Rahma
|
|
|
|
|
Hi Jassim,
Unless I have to refresh the entire grid, I only update individual rows/cells based on what needs to be refreshed - and obviously that's faster than repopulating the dataset and refreshing the grid (iGrid is very fast, by the way). I use grids in unbound mode and I manually populate the grid and maintain/refresh the grid myself. I like working that way better but there might be other ways to populate data in iGrid. I’m not too familiar with that. You may want to send an email to support@10tec.com. They are good at responding emails.
Glenn
|
|
|
|
|
I have a GUI with multiple TextBox and ComboBox controls. These controls are bound to a datasource and are update via the CurrencyManager. How can I detect when a user has started to modify the text in one of the controls?
If I advance to the next record I can check the status of the CurrencyManger and determine is the previous row has changed. I want to be able to detect that the row is changing before the user has advanced (or retreated) rows.
Currently I am thinking that I will need to enable the TextChanged event for each control (controls are created dynamically) and use that to determine if an edit has happend and then disable the event when the user advanced to the next row, and then reenable after the controls have populated with data.
Is that a good way?
Thanks.
www.lovethosetrains.com
|
|
|
|
|
I have a class library which prints a report directly from reporting services. I have a few Console.WriteLine statements. When i insert this library in my main application and use it i see the Console.WriteLine info written in the debug window of the .NET IDE. What i would like is to use this info in my own application. Is there a way to print this information somewhere in let's say a textbox of my main application ?
|
|
|
|
|
If you use System.Diagnostics.Trace.WriteLine (you can't use formating [with '{0}'] directly with this) instead of System.Console.WriteLine , you can tell your App to get the Trace Data with
System.Diagnostics.TextWriterTraceListener traceListener = new System.Diagnostics.TextWriterTraceListener( {a stream to receive the Trace Messages} );
I don't know if you can also redirect the System.Console.Out Stream.
Greets
Roland
Wenn der Computer wirklich alles kann, dann kann er mich mal kreuzweise.
(Manfred Schmidt)
Follow your Euro notes in their tracks
|
|
|
|
|
You can always redirect console output to your own stream, provided you launch the process.
You can write a tiny bootstrapping application that launches your main application after redirecting standard output and also captures console output. Something like
class BootStrapper
{
StreamReader reader;
public static void Launch()
{
ProcessStartInfo info = new ProcessStartInfo();
info.RedirectStandardOutput = true;
...
Process p = Process.Start(info);
reader = p.StandardOutput;
new Thread(new ThreadStart(ConsoleReader)).Start();
}
private void ConsoleReader()
{
string line = null;
while ((line = Process.GetCurrentProcess().StandardOutput.ReadLine()) != null)
{
}
}
}
Or you can replace calls to Console.WriteLine with Trace.WriteLine and use the method that the other poster suggested.
Hope this helps.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
yeah this helped for sure thanks a lot to both of you !
|
|
|
|
|
In Visual Studio 2003, when you add an xml comment (with '///'), the IDE helps you with the intellisense to remember the tag names. As NDoc adds some tags (<exclude /> as an examle), it would be nice to have support for this tags in the intellisense.
Is it possible to extend/adapt the list of tags and its structure (the schema), and how? I've searched in the folder of the ide for a schema file or something like this, but was not successfull.
Thanks
Roland
Wenn der Computer wirklich alles kann, dann kann er mich mal kreuzweise.
(Manfred Schmidt)
Follow your Euro notes in their tracks
|
|
|
|
|
how a tcp server running on given uri like "soap:tcp://localhost:8080/MyReceiver" will return wsdl. In normal web service case which runs on http returns wsdl by simply appending '?wsdl' in url, but I am confused how a tcp server will do the same.
plzzzzzzzzz reply !!
thanks in advance
iffi
|
|
|
|
|
You an use the url with wsdl query string
as
http://localhost/myservice.......?wsdl
Shahzad Raja
|
|
|
|