|
Well, i never tried it, but i think yes. I do the following for a treeview, i suppose you could do the same for a datagrid. One condition. You do not link the context menu to the datagrid.
The code will try to find out the node where you clicked, and if it is a node, show you the contextmenu.
Some additional code is inside because i am using only one context menu, but i am changing some things depending the selected node.
I hope it helps.
private void m_tvAdvertisements_MouseUp(object sender, MouseEventArgs e)<br />
{<br />
if (e.Button != MouseButtons.Right) return;<br />
<br />
Point pt = new Point(e.X, e.Y);<br />
m_tvAdvertisements.PointToClient(pt);<br />
<br />
TreeNode Node = m_tvAdvertisements.GetNodeAt(pt);<br />
if (Node == null) return;<br />
<br />
if (Node.Bounds.Contains(pt))<br />
{<br />
m_tvAdvertisements.SelectedNode = Node;<br />
<br />
if (Node.Tag == null)<br />
{<br />
deleteAdvertisementToolStripMenuItem.Enabled = false;<br />
enableAdvertisementToolStripMenuItem.Enabled = false;<br />
}<br />
else<br />
{<br />
deleteAdvertisementToolStripMenuItem.Enabled = true;<br />
SMSAdvertisementItem i = Node.Tag as SMSAdvertisementItem;<br />
SMSProgramItem p = FindProgramItem(i.PackageID, i.ProgramName);<br />
if (p == null)<br />
{<br />
enableAdvertisementToolStripMenuItem.Enabled = true;<br />
}<br />
else<br />
{<br />
if (p.ProgramEnabled)<br />
enableAdvertisementToolStripMenuItem.Text = "Disable Program";<br />
else<br />
enableAdvertisementToolStripMenuItem.Text = "Enable Program";<br />
<br />
enableAdvertisementToolStripMenuItem.Enabled = true;<br />
}<br />
}<br />
<br />
m_cmTreeContextMenu.Show(m_tvAdvertisements, pt); <br />
}<br />
}
|
|
|
|
|
THNKS
Do u think i can to the nodes at the tree view a checkBox
kobkob
|
|
|
|
|
Yes you can.
In the windows form, click the treeview control, go to the properties window and look for checkboxes, change value to true.
For more info on how to use it I would like to refer you to:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.treeview.checkboxes.aspx
|
|
|
|
|
Hi all..
Hi do I save a copy of XSD..I have a button called save that opens a savedialog. I want to save a copy of my current DataSet as a new file on a path chosen on the Save Dialog. Eg."c:\SavedDataSet.xsd".
Is this chair taken
|
|
|
|
|
The "WriteXmlSchema" of the DataSet class does just that for you.
|
|
|
|
|
I want to disable the xp or 2000 system hot key ,just like ctl+alt+del ctl+shift+esc ect. I use C#.
|
|
|
|
|
This article[^] describes what you are asking. It's in C++ though, so you would need to translate it to C#. Since it's just Win32 API calls, this site[^] would probably help.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
I'm trying to display the name of an application that a particular file extension is associated with
I'm successfully pulling the info out of the registry, but end up with the "shell\open\command" in a format such as
c:\progra~1\app\someapp.exe /a /b %1
or
c:\other\app\otherapp.exe
or
"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE"
or
"c:\program files\something else\wibble.exe" %1
etc
I just need to pull out the full path of the executable, so I can query it's icon - can anyone help?
|
|
|
|
|
Hi..
you don't need to find the path of the application that is associated with a certain filetype.
all you need is this struct:
[StructLayout(LayoutKind.Sequential)]
internal struct SHFILEINFO
{
public IntPtr hIcon;
public IntPtr iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szDisplayName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
public string szTypeName;
};
, this api call:
[DllImport("shell32.dll")]
public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);
and a function that looks like this one:
private Icon getIconForFile(string FileName)
{
Icon RetVal = null;
FileInfo inf = new FileInfo(FileName);
SHFILEINFO shinfo = new SHFILEINFO();
IntPtr hImgSmall = Win32.SHGetFileInfo(FileName, 0, ref shinfo,(uint)Marshal.SizeOf(shinfo),Win32.SHGFI_ICON |Win32.SHGFI_SMALLICON);
RetVal = Icon.FromHandle(shinfo.hIcon);
return RetVal;
}
simly call this function and you'll get the associated icon for your filetype
hope this helps
M@u
|
|
|
|
|
I need the executable's name too (I display a list of applications, but wanted to display the system default one on top)
|
|
|
|
|
Hi
found this ( ([A-Z]:\\[^/:\*\?<>\|]+\.\w{2,6})|(\\{2}[^/:\*\?<>\|]+\.\w{2,6}) ) regex here[^]
it's supposed to extract the filename of your exe only without the parameters
greets
M@u
|
|
|
|
|
I need to change color of some of the text that will be appear on my static label - how can i do it ?
I know that i can use the Rich Text Control ... but i don't want to use the it.
Thanks.
|
|
|
|
|
To change only part of the text, you need to owner draw and write your own code for defining the colors of parts of the text.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Is there is no other way ?
Without writing my own code ?
|
|
|
|
|
Yanshof wrote: Without writing my own code ?
I love comments like this on a development site. (No disrespect to Yanshof here...)
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Yanshof wrote: Is there is no other way ?
Without writing my own code ?
OK - this is a developer site. Surely this is exactly the type of challenge you would want to rise to.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
My application is connected with access database called BaseStudents!
This database have table with name: tblSudents. The first field in table
tblStudents is "StudentID" type:number(long int) and also primary key,
second field is "Name of Student" etc...
So my problem is, when my application will insert some data in table 'tblStudents'
it would look like this:
StudentID Name
1 Jack
2 Tom
3 Mike
4 Peter
5 Paul
6 Maria
7 Jean
8 David
9 Jesse
10 Vik
11 Alex
.....
Then, my application can delete from this table, but if someone
delete records with number: 2,3,4,5,6,7,8
the table 'StudentID' it would look like this:
StudentID Name
1 Jack
9 Jesse
10 Vik
11 Alex
Is there a way,when I delete records, the field 'StudentID'
to have a value: 1,2,3,4,5,...
I mean after deleting the table to look like this:
StudentID Name
1 Jack
2 Jesse
3 Vik
4 Alex
to renumber StudentID, to sequence number, not 1,8,9,10!
Second question:
I need help with select statement...
I know UPDATE,DELETE, INSERT, but SELECT with condition
like this(when I press button "Select", to execute code below)
"SELECT StudentID, Name, FatherName, LastName, years FROM [tblStudents]" + " WHERE Name=" +comboBoxName.Text+", FatherName="+comboBoxFatherName.Text+", LastName=" +comboBoxLastName.Text+", years=" +comboboxYears.Text+";";
So I want to select data who is equal from database tblStudents, and the data who user of my application
will pick from the comboBoxes.First, user pick value from comboBoxes, then press button "select"
and "selected" data should appear in dataGrid or dataView...
Is this correct?
Is this possible?
Please, if you have a free time and if you want to help me, reply to me...
All the best, from c# begginer to c# advanced...
sorry for bad english
kpp
|
|
|
|
|
I recommend you buy a book on SQL and work through it.
replace your , with the word AND, put quotes around the strings, and then it will probably work.
If you have SQL Server, read the books that come with it, they cover all this basic SQL stuff.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yes, but how to put this data in datagrid or dataview
kpp
|
|
|
|
|
Buy a book or use Google. There are only about 1 million examples.
__________________________
Don't drink and derive.
Alcohol and calculus don't mix.
|
|
|
|
|
Some people like to be spoonfed. They can't (or don't want to) look for stuff that's already there.
ROFLOLMFAO
|
|
|
|
|
Hi,
Is there any good way to handle large file (typically 2Gig)? I prefer to read block by block and upload into GUI.
How it will work out ?
|
|
|
|
|
I think that you can read it fast enough with Streamreader. But I don't know what the results will be for your memory...
If you are intending to pass this info into a database. You might wanne create a Data Transformation Service
(DTS) package for the (bulk) insert. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dtsprog/dtspapps_21rn.asp
For the rest I want to suggest you, because you specified GUI, that while reading to a GUI, you don't update/redraw the GUI, because this will slow down the whole process. When passing them to a listview, the good way is:
listview1.BeginUpdate()
READ + ADD TO LISTVIEW1
listview1.EndUpdate()
Good luck, if not satisfied, please provide more details on your project.
|
|
|
|
|
If you're using a 32 bit version of windows, the maximum memory space for an application is 2gig (3 if you fiddle some system settings), so you might find you can't hold the whole file in memory
|
|
|
|
|
Dear Mr and Ms !
I am using C# 2005,
I can not input date type with format 'dd/MM/yyyy' in Datagridview control.
Please help me.
Thank so much !
Thomas
|
|
|
|