|
There is any way to make a control invisible at design time when "Visible" property changed to false?
|
|
|
|
|
No, because you need to be able to see it in order to work with it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi!
I'm using the colorDialog to let the user select a color, then I save it to the registry. Everything is fine except with the user doesn't select a named color. What I am getting save to the registry is something like:
ffff8000
I tried the following:
ColorConverter colConvert = new ColorConverter();
treeview1.ForeColor = (Color)colConvert.ConvertFromString(regkey.GetValue("ColorName").ToString());
But it's not working when the color is not named, e.g. Yellow.
I'm getting:
ffff8000 is not a valid value for Int32.
Please help. Thanks.
|
|
|
|
|
LOL - just answered you on MSDN.
int decAgain = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
There's nothing wrong with the code that you have posted. Just only a misunderstanding of what ColorConverter does. ColorConverter, as you probably have guessed, is only meant to convert a named color, as defined by a constant of Color, to it's Color instance equalivalent.
To convert the hex representation you can use Color.FromArgb()
Post back if there's anything you don't understand.
Graham.
|
|
|
|
|
Just adding on to what Christian has answered:
This should work. (I hope!)
Color c=Color.FromArgb(int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber));
[Edit] Yay! It works!
-- modified at 18:57 Sunday 18th June, 2006
|
|
|
|
|
Thanks guys. It worked.
|
|
|
|
|
The title says it.
Please help. Thanks.
|
|
|
|
|
How about this. Will check to see if registry key exists.
using Microsoft.Win32;
...
string keyName=...;
string valueName=...;
object defaultValue=...;
object o=Registry.GetValue(keyName,valueName,defaultValue);
if (o!=null) {
}
else {
}
|
|
|
|
|
Hello
I am trying to rename a Direcotry/folder in windows
My way to do it goes like this:
private void RenameFolder(DirectoryInfo dir, string NewName)
{
FileInfo fl = new FileInfo(dir.FullName);
fl.MoveTo(string.Concat(dir.Parent + "\\" + NewName));
}
My question is if this is the best way to rename a directory/folder?
Thanks
QzRz
|
|
|
|
|
Hi.
You can also use Directory.Move(string src,string dest)
Or even DirectoryInfo.MoveTo()
So to use your existing code, this can be simplified to:
private void RenameFolder(DirectoryInfo dir, string NewName)
{
dir.MoveTo(Path.Combine(dir.Parent.FullName,NewName));
}
Graham
-- modified at 17:12 Sunday 18th June, 2006
|
|
|
|
|
Hi
Thanks for the reply
Didnt think of you way to do it, thanks
|
|
|
|
|
Hi guys!
Please I need help. I have an MDI form which has click events for ADD, MODIFY and DELETE all these go to the same form which is the "ADD FORM".
For MODIFY AND DELETE click; I need to run a SQL query that will load the data from SQL tables into the textboxes. My question when I open the ADD FORM; how do I process it according to which click made the entry.
i.e.
If (ADD button was clicked from Mdi form)
InitializeComponent()
else if (MODIFY or DELETE were clicked)
connect to SQL table and load data into textboxes
else
I hope this makes sense, all I need help with is how to process the form based on the click.
Please help! thanks in advance.
sasa
|
|
|
|
|
You test the sender object to determine what action to tak:
private void ButtonHandler(object sender, System.EventArgs e)
{
if(sender == this.buttonAdd)
{
}
else if(sender == this.buttonModify)
{
}
else if(sender == this.buttonDelete)
{
}
}
- It's easier to make than to correct a mistake.
|
|
|
|
|
I am assuming I create this function in the ADD form, I did that and then I guess I just have to call it in the beginning initialization after InitializeComponent(). Please don't mind my ignorance but how do I call this Button Hander function. I am calling it using this.ButtonHandler() and it gives me an error saying no overload for method ButtonHandler takes 0 arguments.
Please help! I want to verify which button was clicked in the ADD form and not the MDI form where the buttons are. I.e. Once I am in the ADD FORM I want to check which button was clicked, Add, Modify or Delete. If mdiform.add was clicked then do something else do something else.
sasa
-- modified at 19:37 Sunday 18th June, 2006
|
|
|
|
|
There seems to be some confusions in your code.
SASA_1 wrote: I am assuming I create this function in the ADD form,...
Not exactly. What I created in the previous post is an event handler(delegate). When a button on the MDI form is clicked, the event will be handled in the MDI form, not the ADD form. Thus, the event handler has to be defined by the MDI form class.
That being said, from within the event handler, the MDI form still can call into the ADD form any proper way you want. For example, in the event handler, you may define a button type parameter and pass it to the callback function of the ADD form. Then, the ADD form may take different action based on which button is clicked.
Hope this helps.
- It's easier to make than to correct a mistake.
|
|
|
|
|
Thanks Jun Du for your help. I just decided to recreate another form for modify and delete. That was an easier approach on my side.
sasa
|
|
|
|
|
Hi, How can I use edit, Update, Delete coloumns in DataGrid in Windows application as we use in web,
hope that u send me a sample
Thanks alot
Hamody
|
|
|
|
|
In the index of your MSDN write "DataGrid control [Windows Forms]"
You should have an article talking all about it.
|
|
|
|
|
I'm using the graphics drawstring function to display a whole page of text. Can can I make some of the text linkable?
|
|
|
|
|
I think you'd have to draw the "blue" text yourself, handle the mousemove event to change the cursor and handle the mousedown / mouseup / click event and decide where the mouse was and if the link is to be activated.
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
|
|
|
|
|
Have you tried using System.Windows.Forms.LinkLabel class?
Graham.
|
|
|
|
|
can it handle both painted text and link label at the same time?
I tried using both painted text and label (not link label) and the painted text were not displayed. So I assumed it would have the same problem?!!!?
|
|
|
|
|
Yes, the control handles the user interaction of the hyperlink for you and renders the text and link both at the same time. It will even change the color of the hyperlink when visited (akin to IE/Firefox and other browsers).
Just locate the control as the position you require using .Location
|
|
|
|
|
It seems working now. Thanks a lot.
|
|
|
|