|
Hi all,
I am looking for code which could help me to disable checkbox for treenode, I had look at Threestate checkboxes article shared on CP, however I want to display Image for Treenode as well, so cant use that code(Threestate checkboxes are displayed as images in that article code).
If anybody help me to achieve this that would be very appreciable.
Thanks in advance
|
|
|
|
|
I have a code for the same.
this.tree.DrawMode = TreeViewDrawMode.OwnerDrawText;
this.tree.DrawNode += new DrawTreeNodeEventHandler(tree_DrawNode);
void tree_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
if (e.Node.Level == 1)
HideCheckBox(e.Node);
e.DrawDefault = true;
}
private void HideCheckBox(TreeNode node)
{
TVITEM tvi = new TVITEM();
tvi.hItem = node.Handle;
tvi.mask = TVIF_STATE;
tvi.stateMask = TVIS_STATEIMAGEMASK;
tvi.state = 0;
IntPtr lparam = Marshal.AllocHGlobal(Marshal.SizeOf(tvi));
Marshal.StructureToPtr(tvi, lparam, false);
SendMessage(this.tree.Handle, TVM_SETITEM, IntPtr.Zero, lparam);
}
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Hi there,
I have a problem with a drived Form.
I have FormA with a Grid on it and FormB and FormC wich are derived from FormA.
Some information of the Grid have to be loaded(in the constuctor) and saved(in the destructor) and do do this correct,
so I need the name of the derived Forms(FormB & FormC).
I tried to get the name from the callstack, but when i have a FormD which is drived from FormC,
the whole thing wont work.
It is possible to get the name of the Form(FormB, FormC or FormD) dynamically, even if it is a derived Form?
Thanks in advance
|
|
|
|
|
Nope, you will not get name of derived form in this manner.
Do one thing. Define one form object inside the parent form as follows.
Form f1;
Now, whenever you create child form assign object of child form to this object
which is of parent form, as follow.
derived from ParentForm.
Public ChildForm():base(this)
{
}
public ParentForm(Form _f1)
{
f1=_f1;
}
That's it. Now, you have whole child form inside the parent form. You
can do anything using f1.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
As the OP described it, this is not a parent/child issue but a polymorphic one. If it were a parent/child one, what you have suggested is a quick and easy, but nasty and bad solution. It's almost never a good idea for a child to be aware of (never mind explicitly bound to) it's parent.
If this is the way you normally handle things I suggest you learn about events/delegates so you can in future write proper OOP code. Just because the way you suggest works, doesn't mean it's good and should be recommended.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
hi DaveyM69,
Thanks for you suggestion.
However, I never told that the solution I gave is best one or does not have any
side effects.
I have just suggested one of the quick and easy solution, that I thought.
Anyway, thanks once again for your suggestion.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
you probably want the type information, not the name. You could use the GetType() method, or the is/as keywords. But I don't think you should go that route.
If FormD needs a different finalization from FormA, you really should solve it by providing it with its own specialized Dispose() method.
Since disposing/finalization are non-deterministic (e.g. they won't always happen when your app terminates), you should solve this differently, probably based on the FormClosing/FormClosed events (which you can override too so you could specialize them for all kinds of Forms).
|
|
|
|
|
That sounds like a bad OOP design. A base class should never need to know about any derived classes.
You could write a factory or manager class that knows what's going on and can do what's needed.
But you probably just need to get the polymorphism right.
|
|
|
|
|
Why do you need the name of the form? I assume you mean the class name and not the name of the instance variable. If you used generics in your methods that would probably solve a whole lot of this.
|
|
|
|
|
I need the name of the form to load(in the constuctor) and save(in the destructor) some information of the grid.
So I need the name of the instance variable to get a unique name.
|
|
|
|
|
Hi guys,
I'm using Visual C# to program a WinForms application. I'm using ClickOnce as deploy method, which working fine, and I have a GoogleCode directory to handle with the SVN sstem (using AnkhSVN installed in VS08 at the moment).
But I'm missing some way that I can show a changelog when the ClickOnce says to the user that there is an update of the application, on application start. What tools do you guys use for the changelog system?
And another question, I just have a plain ClickOnce installed now, but is it possibel to make my own installing screens for the ClickOnce application, where I can get the user to choose some setups etc.?
Hope some of you VS experts will help me. Imo its some nice features that is very useful (and doubt they doesn't exist)
|
|
|
|
|
|
Hi All,
Hope everyone is well? I'm hoping somebody could point a newbie in the right direction?
Basically we have a mailbox on our exchange server called backups@domain.co.uk.
This mailbox receives all the backup logs from our 30+ servers, and each mail contains an attached TXT or HTML file. I need the app to either monitor the mailbox direct or via using outlook, when the mail comes in the app should look at the subject line, take the attachment and move it to a folder under the servername (Found in the subject line) and then save the textfile with the days date.
For example SERVER1 in the subject line - The App should move the attached text file to:
C:\BackupLogs\Server1\16-07-2010
Hope that makes sense. Im fairly new to c# but dont mind a bit of reading. I would be greatful if someone could point me in the direction of a example app or code/reading meterial?
Cheers
Si
|
|
|
|
|
|
Hi
I`m creating a C# desktop application that acts as a portal to various other fearures, one of which is Skype. My application will have multiple users. I will store each user's Skype login details in a SQL database. Would there be any way to log a user in automatically using the user's username and password from the database?
The process flow must be something like this:
User clicks on Skype button > Skype launches > Corresponding user's details are read out the database > User logged into Skype without username and password prompt
|
|
|
|
|
|
First of all, I know this question is only partially relevant to C#, so sorry for posting it here.
I am trying to implement Facebook single sign on using a desktop application. The one thing I figured out so far is to retrieve an access token.
How I retrieve the access token:
browserFacebook.Navigate(@"https://graph.facebook.com/oauth/authorize?client_id="+ FacebookApplicationID + "&redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=popup");
This redirects the user to page where he/she must first authorize the application. Once authorized, I redirect the user to "http://www.facebook.com/connect/login_success.html" as specified in the above address. I then intercept this URL to retrieve the access token like so:
string someString = browserFacebook.Url.ToString();
This returns something like the following:
"http://www.facebook.com/connect/login_success.html#access_token=ACCESS TOKEN.expires_in=0"
I can then easily use this access token with the Graph API to access an users facebook details as in the following code:
Facebook.FacebookGraphAPI g = new FacebookGraphAPI("ACCESS_TOKEN");
var fbUser = g.GetObject("me", null);
Can I also use this token somehow to simply log a user in to the site? My goal is not really to develop a complete new facebook application as my application is simply a prototype.
|
|
|
|
|
Hello everyone,
I am trying to set a column in my datagridview to be as datetimepicker column only.
It is so easy to do it if my datagridview is not binded within database, i did it by making a user control which transform datagridviewtextboxColumn to datetimepicker from Calendar().
But my question: i dont want to add a new column in my datagridview of type datetimpicker or maybe something else like datagridviewComboBoxColumn or else, i just want to change my column type:
For example changing DatagridviewTextBoxColumn to datetimepicker
or
DatagridviewTextBoxColumn to DatagridviewComboboxColumn
This can be done easily by setting my datagridview columns to specific columns, but my main concern is that my datagridview is already binded.
Hope i can have any help, coz this issue took lot of my time.
Thanks in advance.
Ronald
|
|
|
|
|
You cannot change column at run-time.
You cannot turn combobox column to datetimepicker column at run-time.
You can only decide column type at creation time.
Refer this[^] link for more information.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Hi
I'm using a WebBrowser control to enable users to browse Facebook, or atleast this is my goal.
Once I retrieved a Facebook session key, how do I redirect the browser to the Facebook Home page? Also, can I store a session key for each user and use this to log them in without having to prompt them for login details each time?
I retrieve the session key by directing the web browser to the url below and then intercepting this url:
browserFacebook.Navigate(@"http://www.facebook.com/login.php?api_key=" + FacebookAPIKey + @"&connect_display=popup&v=1.0&
next=http://www.facebook.com/connect/login_success.html&cancel_url=http://www.facebook.com/connect/login_failure.html&
fbconnect=true&return_session=true&session_key_only=true&req_perms=read_stream,publish_stream,offline_access");
|
|
|
|
|
I'm not familiar with Facebook, but isn't the API key tied to the application? (As opposed to the user?)
You can register your application here[^], and they'll provide a key for your application.
I are Troll
|
|
|
|
|
Yes it is, but I was talking about the session key, not the API key
|
|
|
|
|
The Session is only valid for 24 hours.
I are Troll
|
|
|
|
|
Apparently not if you set the expiry time to 0. Anyway, I don't think this is the best way to try and implement single sign-on. I'm just giving it a shot since I'm kind of at a dead end. I've got all the users' usernames and passwords, I just need to find a way to log them in automatically
|
|
|
|
|
Etienne_123 wrote: Apparently not if you set the expiry time to 0.
Don't know where you got this information, but the docs[^] state something else;
Users don't log out of desktop applications. A user's session expires after 24 hours,
or when the user closes your application. If you need to, you can terminate a user's
session by calling auth.expireSession.
I are Troll
|
|
|
|