|
Thank you for letting us know that. Did you have a question you wanted to ask?
|
|
|
|
|
now check again please.
|
|
|
|
|
Well if you create a ContextMenu(Strip) which you assign to the treeview. There's an event for that which is fired when the menu is displayed (can't remember the name of it).
If you handle that event then you can decide which menu items to display. Then when a menu node is clicked you need to decide which context it's been fired in (i.e. sub node etc) and perform the appropriate actions.
To copy / paste the treenodes I'm not sure how to accomplish this at the moment using the clipboard (easily anyway), if it's to be handled by the program then you could just store a copy of the code in a local variable and delete it from the tree and move it to the appriopriate place.
|
|
|
|
|
This is ugly ugly code but ...
Uses a TreeView treeView1
ContextMenu cMenu;
int count;
public Form1()
{
InitializeComponent();
cMenu = new ContextMenu(new MenuItem[]
{
new MenuItem("Add before", new EventHandler(mi_Click)),
new MenuItem("Add after", new EventHandler(mi_Click)),
new MenuItem("Add child", new EventHandler(mi_Click))
});
treeView1.Nodes.Add(createNode());
}
private TreeNode createNode()
{
TreeNode tn = new TreeNode("Node" + (count++).ToString());
tn.ContextMenu = cMenu;
tn.ContextMenu.Tag = tn;
return tn;
}
void mi_Click(object sender, EventArgs e)
{
MenuItem mi = (MenuItem)sender;
TreeNode sourceNode = (TreeNode)mi.Parent.Tag;
switch (mi.Parent.MenuItems.IndexOf(mi))
{
case 0:
if (sourceNode.Parent != null)
sourceNode.Parent.Nodes.Insert(sourceNode.Index, createNode());
break;
case 1:
if (sourceNode.Parent != null)
sourceNode.Parent.Nodes.Insert(sourceNode.Index + 1, createNode());
break;
case 2:
sourceNode.Nodes.Add(createNode());
break;
}
}
|
|
|
|
|
I am a newbie to C#. I was trying to refresh a drawing in a UI panel. Can I set a timer to call itself after 1 second? The event type is a PaintEvent and I don't know how to call this event.
If anyone could help I would be grateful.
|
|
|
|
|
Hello,
You could use Invalidate or Refresh.
All the best,
Martin
|
|
|
|
|
Hello,
t2o2uk wrote: I don't know how to call this event
In general you can not call this event directly.
If you inherit a class from System.Windows.Forms.panel, you could override the OnPaint Method which is called from the event.
This would be recomended if you whant to change the behavior or style of more than one panel in your application.
Hope that helps.
All the best,
Martin
|
|
|
|
|
Add a Timer control to the page that you can use to update periodically. At each tick you call the Invalidate method of the control that you want to update, and it will be redrawn.
---
b { font-weight: normal; }
|
|
|
|
|
Was just whipping up a quick util which immediately executes an assembly normally run by a winservice at night. The assembly implements an interface exposing a DoWork() function.
I decided to play with the BackgroundWorker component to keep my utils UI responsive and show a little animation while it chugs along. So I have a worker class which essentially implements the interface and calls DoWork().
I thought it would be cool to implement a cancel button while I was at it. BackgroundWorker supports a CancelAsync() which requires the worker thread to check backgroundWorker.CancellationPending and then return. But what if my worker is calling in to an assembly which is performing the long process?
Just curious if there is a way to forcing a BackgroundWorker to immediately cancel. A call to Dispose() was ignored and I didn't see a way to force the thread to exit immediately.
|
|
|
|
|
There isn't a way, no. You can terminate the thread via Thread.Abort, but that's generally a bad idea since it can leave your code in a volatile, unstable state.
I recommend having your background worker spawn a new thread in the DoWork handler. Have that thread do the actual work, while the DoWork thread do 2 things: continually check for the cancel flag, and continually watch for completion of the spawned thread. When either the spawned thread finishes or the cancel flag is true, your DoWork thread can return, thus your RunWorkerCompleted handler will be fired.
p.s. check out Roy Osherove's extended BackgroundWorker[^], which includes a CancelImmediately() method that accomplishes pretty much what you're trying to do.
|
|
|
|
|
I make a chart in steema tchart and convert it in EPS file.
and now showing it in Latex, but it not work because EPS file is not standard.
Anybody please tell me what should i have to do?
Tahnks
ArvindHaritus
|
|
|
|
|
Hey guys,
I display a tooltip whenever a mouse moves over an item in my listview control. However, the width/height of the tool tip is determined by the content inside the tool tip. is it possible to override this and display a fixed width tool tip?
|
|
|
|
|
I'm trying to build prototype and want some objects filled with random data. I've copied my production interfaces into the prototype project and built some dummy classes based on them.
In the load method of one class i've added a bit of code to populate the private members with data.
When i instantiate a few objects and put them in a collection they all end up containing the same data. When i put a break point in the code to see what's going wrong though, they all come out with different values.
Does Random.Next() or Random.NextDouble() use the system time? I don't really understand what could be happening here.
Any ideas would be greatly appreciated
Russ
|
|
|
|
|
Use a single Random object in the code instead of creating a separate one for each object. The Random object is seeded from the system time when created, so if you create Random objects to closely in time, the randomness will not be good.
Another possible reason is if you actually don't instantiate separate objects, but instantiate only one single object and fill if with data over and over again. When you add the object to the collection, the object isn't copied, it's only the reference to the object that is stored. When you are done you have a collection full of references to the same object, which of course will contain the same data regardless of which reference you use to look at it.
---
b { font-weight: normal; }
|
|
|
|
|
i've just found a solution.
I tried to initialize the Random object with a seed of Environment.TickCount and still had the same problem when i ran it, but the second time i noticed the repeated number changed half way through my list. Made me think that maybe the Random seed only changes every 1 ms. I've added a Thread.Sleep(1) to my code and it works. It's only for building a prototype so i'm not too bothered how it works as long as it works.
Thanks for getting back Guffa (I thought i'd managed to use the same object for a while there too, had a long look to make sure i hadn't)
Russ
|
|
|
|
|
Well, anything that works...
The proper way to solve it is of course to use a single instance of the Random class. If you don't want to pass around the reference, you can make a factory method that will create a single instance:
private static Random rnd = null;
public static Random GetRandomGenerator() {
if (rnd == null) rnd = new Random();
return rnd;
}
---
b { font-weight: normal; }
|
|
|
|
|
hi
i have a datagridview and i want to change the current row style, changing its background color to yellow. it`s ok when i react to CellClick, but i want to select a row also if the user press the up or down keyboard keys.
ok, but, when i react to CellEnter or RowEnter, it`s coloring all the datagrid rows when the program first runs. how can i solve this problem? i just want to color a entire row when the current row cell is selected.
the code to color an entire row i`m using is the following:
<br />
foreach (DataGridViewCell cell in dgvPedidoItem.Rows[e.RowIndex].Cells)<br />
{<br />
cell.Style.BackColor = System.Drawing.SystemColors.Info;<br />
}<br />
thanks everyone in advance... XD
|
|
|
|
|
add the CellEnter or RowEnter event handler once the form has been drawn and the datasource set.
public Form1()
{
InitializeComponent();
dataGridView1.DataSource = ............;
//IN HERE FOR EXAMPLE
dataGridView1.CellEnter +=new DataGridViewCellEventHandler(dataGridView1_CellEnter);
}
|
|
|
|
|
Hi guys,
What I am having very hard time to achieve is to build an "Article Layout".
This means to have : Title, related image, and body-text, just like we can see in CNN articles for example.
Doing this in HTML is easy using the CSS float property.
I can't find a way to do it well in winforms.
I don't mean to create 2 columns: 1 for the image and 1 for the text, because thats easy.
I want to have the body text to wrap around (float around) the image.
Any idea will be appreciated.
Thanks.
|
|
|
|
|
Do you have any experience rendering (painting/drawing)? That is what you would have to do to achieve your goal. It basically involves a lot of pixel math and GDI calls to do the painting.
led mike
|
|
|
|
|
Hi
can i call a webmethod from another webmethod in the same webservice?
regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
... you can ... Why do ask?
SkyWalker
|
|
|
|
|
Hi folks,
I am new for .Net 2.0, i want to use the appsettings values now i have using
following code and i add reference for configuration component manually but its not working.
|
|
|
|
|
- English please
|
|
|
|
|
hi folks,
I am new to .net , Now i have work with Windows application and i want to read the file from specific path. I have using filestream object for file access but it shows following error.
Access to the path 'C:\\Program Files\\AAA' is denied."
my code is,
FileStream FS = new FileStream(@"C:/Program Files/Psis/Conf.xml", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
is anybody face this problem before plz tell me the solution.
|
|
|
|