|
I'll keep that in mind...
Anyway... I've read somewhere that Close() is the same as Dispose().
What's the difference?
|
|
|
|
|
If you're using multiple threads and something weird is going on, assume multiple threads are modifying/reading the same resource (in this case, a file stream). I'd suggest doing some debug work to verify that 2 threads aren't trying to access the same file.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Islamic Domination: Coming to a Jewish state near you!
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I'm somewhat new to threading...
Could you tip me as for how to check stuff like that?
I know there's the "Debug Location" toolbar, which can help...
But is there anything other than that which might be useful?
|
|
|
|
|
|
Thanks a lot you guyz!
Been hacking at it for more than a week!
Almost gave up! (HAHA! No chance of that happening )
Thanks again...
PS
Judah... Would you still give me those tips please?
Shy.
|
|
|
|
|
Hi. I've a NotifyIcon and a ContextMenu with some options. The problem is that I want to press Left Click (primary button) to open the contextMenu.
I resolve that in this way, may be someone have a better idea (it'll be welcome !!
private void notifyIcon_MouseClick(object sender, MouseEventArgs e){
Control ctrl = new Control();
ctrl.CreateControl();
Point pos = Cursor.Position;
pos.Offset(0,-30);
this.contextMenuAplicacion.Show(ctrl, pos,LeftRightAlignment.Left);
}
The problem is if I press the left button over the icon I see the menu, but if I press the button and then I move out and I click in another window for example the internet explorer, the contextmenu is still there and it's like it's there forever, I must select one option of the menu to close it.
Any ideas? Any of you have an example of use left click button to this notify icon to show me a contextmenu??
Thanks a lot people !!
|
|
|
|
|
Why get so hard?
if (e.Button == MouseButtons.Left)
contextMenuStrip1.Show(MousePosition);
as simple as it gets as simple as it needs!
this will show the contextmenustrip on the mouseposition when left button will be clicked.
and if you must incist:
contextMenuStrip1.Show(MousePosition, ToolStripDropDownDirection.Left);
|
|
|
|
|
Thanks NaNg15241, but if you click another window, you'll see that the contextmenu is still there.
Thanks a lot.
|
|
|
|
|
Well, you can solve it in many ways, one of them is implementing the "mouse leave" event in the context menu to hide it or dispose it. something like this:-
private void contextMenuStrip1_MouseLeave(object sender, EventArgs e)
{
contextMenuStrip1.Visible = false;
//or maybe contextMenuStrip1.Close();
//or any other code to hide or dispose the menu
}
This way, the menu will stay hanging on the screen until the user moves his mouse over it and then out of it, then we will know that he noticed the menu, but doesn't want to make a choice now, and the menu will close.
Another way is to se the contextMenuStrip1.Show() method in the MouseUp of the notifyIcon event to check the position of the mouse first, like:
private void notifyIcon1_MouseUp(object sender, EventArgs e)
{
if(e.Button == MouseButtons.Left)
conextMenuStrip1.Show();
}
This way the menu will not show unless the mouse button has been released over the notify icon.
If this doesn't solve it and you still need help, just post.
Programming is like sculpturing, cutting your way through the rock until you see a shape of your work.. It needs patience.
-- modified at 20:14 Monday 15th May, 2006
|
|
|
|
|
Hi Nader, is there a mouseLeave event for the contextMenu? I'cant see it.
Thanks a lot.
|
|
|
|
|
Well, that depends on whether you are using the old ContextMenu control, or the new ContextMenuStrip control which has MouseLeave event.
If you insist on using the older ContextMenu control you may use a timer to check for MousePosition or maybe perform a HitTest, but I strongly suggest the contextMenuStrip control.
I hope I was of some help
|
|
|
|
|
Thanks a lot Nader !!. I update my information . I have now this problem, may be you had see it, when I click (left button event) on the notify button and call the show method like this:
this.contextMenuStripOp.Show(ctrl, Cursor.Position, ToolStripDropDownDirection.Left);
I see in the Task bar a window of the contextMenuStrip. But when I press the right button the window isn't in the Task Bar.
Thanks !!
|
|
|
|
|
I see. That is because you show your contextmenustrip by the "show" method. and by default the "TopMost" property is set to true. This way your context menu will show an icon in the taskbar.
You have to set it to false first then show you menu. unfortunately this may make your menu not to show at all because it's niether a topmost, nor a child to any control. It's a bit of a predicament. I haven't solve it yet, but you try to make the topmost false, and figure a way to show your menu as achild of another control "but notifyicon won't work". I will work on it later on this night. If I get to something I will keep you posted.
|
|
|
|
|
|
Basically I have a framework of assemblies that can be accessed via multiple methods (i.e. web services, COM, direct .NET referencing etc). Interfacing applications create and destroy instances of these assemblies at will and I have no control over this applications.
The issue I have is that these assemblies use a backend database to store large amounts of data that rarely changes. Constantly hitting the database is a performance hit, therefore I am looking for a mechanism to cache the data so that regardless of how the assembly is created/destroyed the cache is available (unless explicity cleared).
The caching I need is relatively simple, essentially everything will be stored as a key/object pair and I do not require cache timeouts etc. With this in mind I have the idea of creating a windows service that will act as the cache (most likely a HashTable or similar variant). As this would be a seperate process it is not linked to construction or destruction of the main code and will give me a consistent cache.
However, I am not sure if this is possible, so here are a few questions:
1) can anybody suggestion an alternative.
2) If the Cache service is running, how would I access that process in order to set/get cache values? (maybe remoting??)
3) Can anybody point out any pitfalls in the plan?
EDIT : This is targetted at .NET 1.1
-- modified at 10:34 Monday 15th May, 2006
|
|
|
|
|
Look at an Persistance layer like Gentle.NET.
|
|
|
|
|
Hi all,
is there any way to customize the looking of the column header of datagrid??
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
No easy way. Overriding OnPaint (or catching the Paint event) and drawing over the existing ones is the only way.
|
|
|
|
|
How do I know if the current cell is the header cell when I override the paint method?
thanks!!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
As said not trivial.
The grid has a GetCellBounds function which you can use to determine the bounds of a cell. The problem is that this doesn't include header cells. But if you have the bounds of the cells in the first row you should be able to calculate where the header 'should' be. If you have this you will have to repaint every header cell everytime Paint is called.
|
|
|
|
|
I don't think I get it!! If you are asking about customizing the column header at design time, just look at the properties window. Look for a property named "ColumnHeaderDefaultCellStyle". There you can change the color, font, formatting, and anything else you want in the Column headers appearance at design time. There are also some other properties in the properties window that you can change (eg. BorderRaised property). If your question was about changing the look of a certain column header at run time, you can use either use "DataGridView1.Columns[X].HeaderCell" (where X is the column number), to access the header cell directly, or one of the followings:
DataGridView1.ColumnHeadersBorderStyle;
DataGridView1.ColumnHeadersDefaultCellStyle;
to change the border style and the cell style respectively at run time.
I hope that solves it. If it doesn't, post me more details of what you need, maybe I can help.
|
|
|
|
|
hi,
actually I am using the DataGrid control (not DataGridView) from the vs2005. I know is not recommanded. but for some history reason I have to use it. also I bind the grid to a arraylist. I want show the triangle icon when I sor the selected column. I just want to simple sort the arraylist and use refresh to update the binding. it works, but I can not see the little triangle.
do you have any idea about this???
Thanks a lot!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
Well, now I can see your problem. I'm not sure this will be easy but I think if you have to override th OnPaint event you can put an if statement at the begining to check for the CurrentCell or RowIndex properties to make sure that you are in the header row, but I don't know how that be of any help.
Another way I can think of doing this is by putting a + or - in the header cell's text;P, I know it's silly but I can't think of anything else right now!! I even tried to use the ascii code to put the triangle (Codded 1E for up & 1F for down) in the text but it doesn't work!
while I was digging up I also found "dataGrid1.TableStyles[0].GridColumnStyles[x]" property!! maybe it will be of some assistance.
You may also get the ClientRectangle, or the Displayrectangle of the DataGrid. Then add the widthes of the columns before the selected column to 0 and this will be the location of your column. Then use the System.Drawing to draw your rectangle in the header's area.
But what's worth all this effort?!!
-- modified at 17:46 Tuesday 16th May, 2006
|
|
|
|
|
Hello everyone,
I have inherited a piece of code that is using a resx file to embed icon in it. These icons are then used in a class. The icon node looks something like this
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 ....
Well, I have never done anything like this before, but i need to add a "+" icon to my app. How do I go about getting the "binary value" for my icon.
Any help would be tremendously appreciated.
Thanks
Sameer
|
|
|
|
|
There are several ways to get resources into your project. One way is the following:
1. Add the icon to your project (rightclick -> Add Existing file)
2. Change its 'Build Action' property to 'Embedded Resource'
3. In your code write the following:
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
Stream inputStream = assembly.GetManifestResourceStream("YourNamespace.YourFile.ico");
Icon yourIcon = new Icon(inputStream);
The code assumes that the icon is in the same assembly as the code which accesses it. 'YourNamespace' is the one you can set in the properties of each project.
|
|
|
|