|
Hi ! I have a Context Menu associated with my datagrid and I want to remove it or disable some menu option depending on which column the user Right Click (to show the context menu).
Thank you !
Danny Gilbert
Montréal, Canada
|
|
|
|
|
Newly starting on C# I am attempting to use the TreeView to show a set of heirarchically related data items. In VisualC++ I would simply add to each node a pointer to the relevant data structure. I could then dereference the pointer and be directly at the relevant data item.
Is there an equivalent function or alternative method of connecting a treeNode to a class containing the data being displayed?
Your guidance would be much appreciated.
Craig Sheppard
|
|
|
|
|
There are two ways you can achieve what I think you are asking.
The fast and easy way is to use the TreeNode.Tag property to store a reference to whatever the TreeNode is supposed to represent. The Tag property is of type Object so it can hold a reference to anything, that can be good or bad because you can have nodes holding references to different types of objects. It also means you have to cast the reference back to whatever type it's suppose to be when you want to use that object.
The slightly harder way is to derive your own class from TreeNode and add an extra property that holds a reference to the object that the node is supposed to represent. This way allows you to ensure that only the right type of object is represented and saves you the hassle of having to cast everytime you want to access it.
|
|
|
|
|
Thats just the thing I needed to know. Many thanks for that.
craig
|
|
|
|
|
Hi,
I understand the code below. The question is indicated by ////???? ?????////// further down.
Thanks
public class clsName
{
public static string CardId
{
...
}
}
///////???????Please explain why static may be used with the private access modifier??????////////////////
public class clsName
{
private static string CardId
{
...
}
}
Thanks
|
|
|
|
|
Other (static) methods in the class can still access the private static variables, but you can't access them from outside. I.e. clsName.CardId is not accessible from outside the class.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Yes, I understand that, but what is the benefit of having static private for the method?
Thanks
|
|
|
|
|
That's from the Levenshtein distance I programmed recently:
class Levenshtein
{
static private int Minimum(int a, int b, int c)
{
...
}
static public int Difference(string s, string t)
{
array[i, j] = Levenshtein.Minimum ...
}
}
Difference is the only method accessible from outside. Since it's so simple there's no need to create a class instance, so I made it static. But Distance needs a Minimum-method to retrieve a value. This must also be static, but I don't want it to be accessible from outside the class.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I guess my question in your case is that why minimum is static?
Thanks
|
|
|
|
|
fmardani wrote: I guess my question in your case is that why minimum is static?
Because it doesnt need or use instance data. There will be marginally less overhead on calling the static method/member repeatedly. You could have omitted static.
It's also common for private helper methods.
xacc.ide-0.1.1.4 - now with LSharp integration and scripting :)
|
|
|
|
|
Any method that doesn't use any data from an instance of the class, should be static. That way, you can always tell if a method is using data from the instance or not.
---
b { font-weight: normal; }
|
|
|
|
|
Because static methods like "Difference" can't access non-static methods.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
To reduce memory consumption should all instances of a particular class need read-only access to the same value. If they also need write, then you need to synchronize access to the member.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
fmardani wrote: ///////???????Please explain why static may be used with the private access modifier??????////////////////
The simple answer is: because it doesn't need be more visible than that.
As a general rule, you should make your methods/properties no more public than they need to be. This makes it easier to refactor the class later if you choose to.
Regards,
Alvaro
|
|
|
|
|
Hi I'm looking for ANY resources on financial problems and their solutions in .NET 1.1. Especially various multi currency and rounding issues. If you know ANY resource be it web, book, event or course please tell me about it.
Thanks in advance!
Kind regards,
Johannes Hansen
frontAvenue A/S
-- modified at 7:47 Friday 6th January, 2006
|
|
|
|
|
Dear All,
I want to write a code for backup and restore of sql database in C#. Please help me for code.
PS-I know how to execute Stored procedures and queries of SQL in C#
With Regards
Manoj
|
|
|
|
|
hey guys i want to restrict paste option for my textbox control in windows application.
how do i do this in c#
|
|
|
|
|
Trap the Ctrl+V event on the textbox and
clear the Clipboard before the paste event
Regards,
Pramod
|
|
|
|
|
Yadav Pramod wrote: clear the Clipboard before the paste event
Why is this necessary? It seems overly aggressive to silently clear the contents of the clipboard.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
You may be able to implement this by (a) removing the Paste item from the textbox's context menu (accessible using the ContextMenu property) and (b) handling the KeyPress event to ignore Ctrl/V.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Have a look at this[^] article. It traps the paste event (overrides WndProc and handles WM_PASTE), which is what you wanted.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
Lets say I have a website called www.ABC.com, which is the main site. I have other sites, for example www.ABC.co.za, and www.abc.com.au. If the user selects www.abc.com, it must determine that the user is from Australia and redirect him to www.abc.com.au.
The above sites I used just as examples. But I think eBay has this feature.
If anyone has such sample code, please let me know.
Regards
ma se
|
|
|
|
|
You have to determine this by ip address then redirect them to the contry subdomain.
here is some sample code.
' This sample code is provided as is, for aiding understanding.
' I make no warranty about its fitness for purpose.
' If you find it useful please use it.
' Don't expect me to sort out any problems unless you are prepared to pay me.
' Written by Paul Stanley Software http://www.pssuk.com
' Set IP string, 1st check for proxy
sIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if sIP = "" then
sIP = Request.ServerVariables("REMOTE_ADDR")
end if
' Handle extended IP addresses
nComma = Instr(sIP, ",")
if nComma > 0 then
sIP = Left(sIP, nComma - 1)
end if
set oConnIP = CreateObject("ADODB.Connection")
sConn = "Driver={Microsoft Access Driver (*.mdb)}; Dbq="
sConn = sConn & Server.MapPath(".") & "\IPCountry.mdb"
sConn = sConn & "; Uid=admin; Pwd="
oConnIP.Open sConn
set oRSip = CreateObject("ADODB.RecordSet")
oRSip.ActiveConnection = oConnIP
oRSip.CursorLocation = adUseClient
nIP = Dot2LongIP(sIP)
sSQL = "SELECT [CountryShort] FROM [IPCOUNTRY] WHERE " & CStr(nIP) & " BETWEEN [ipFrom] AND [ipTo];"
oRSip.Open sSQL, oConnIP, adOpenForwardOnly, adLockReadOnly
sCountry = oRSip("CountryShort")
function Dot2LongIP (ByVal DottedIP)
Dim i, pos, PrevPos, num
' Convert IP String like "1.12.124.22" to 32 bit integer
if len(DottedIP) < 7 or isnull(DottedIP) or DottedIP = "unknown" then
Dot2LongIP = 0
else
PrevPos = 0
for i = 1 To 4
pos = InStr(PrevPos + 1, DottedIP, ".", 1)
if pos = 0 then
If i = 4 Then
pos = Len(DottedIP) + 1
else
Dot2LongIP = 0
exit function
end If
end if
num = Int(Mid(DottedIP, PrevPos + 1, pos - PrevPos - 1))
PrevPos = pos
Dot2LongIP = ((num Mod 256) * (256 ^ (4 - i))) + Dot2LongIP
next
end If
end function
|
|
|
|
|
Hi all,
Currently .Net supports multiple file types such as bmp,jpg, gif etc just to name a few , which is supported by Image class
Can anyone please help me, how can i convert a bmp file to a raw format file using .NET?
|
|
|
|
|
What format do you mean by raw format? There are a whole bunch of them...
---
b { font-weight: normal; }
|
|
|
|