|
hi
i want to change datagrid properties in form1 from other forms .. how to do this ???
i tested some waye (using public modifier for datagrid in form1 or using property to return datagrid properties or method that change datagrid properties from other forms but did't get result)
Please Help me how to this ???? (please give me a full details solution because i am beginner)
thanks ..
|
|
|
|
|
hi i want to save app setting in file and load it for next times ...
how to do this ???
(Please give me a full tutorial because i am beginner . thanks)
regards...
|
|
|
|
|
|
hi and thanks
the xml app setting is useful but only save string values . for example i want to save
datagrid1.AlternativeBackColor in app.config and retrieve it in form.load event . how to do this ?
thanks ...
|
|
|
|
|
hdv212 wrote: want to save datagrid1.AlternativeBackColor
AFAIK, the config file only stores strings. You could easily convert the color to a numeric value and store its string representation (name or RGB values) and do the reverse on the way out.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
How to convert a Color object to and from a string, for storing somewhere, has already been answered in your previous post regarding saving this value to the registry.
Please check there first. Once you understand this, the question of how to write it/read it to some form of configuration file is easy, and should be explained in the article linked above.
|
|
|
|
|
This just baffles me!
I know it is something simple and right under my nose but cant figure it out
static void Main(string[] args)
{
MessageBox.Show(args[0]);
}
How do i pass in arguments prior to running this program.
|
|
|
|
|
1) Create a link, and add them to the textbox that points to your program
C:\Programs\MyFile.exe -parameter1 -parameter2
2) Open the command prompt and do the same:
> MyFile.exe -parameter1 ...
3) In Visual Studio:
Menu: "Project -> [Program] properties..."
Then on the left: "Debug" and in the middle: "Command line arguments"
There are plenty of other possibilities, but these are the most common ones.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Alternatively, create a shortcut to your application and edit the shortcut by Right-clicking and selecting properties.
On the 'Shortcut' tab, just add the arguments you want in the target box so:
Target: "C:\program files\my app\my app.exe"
would become:
Target: "C:\program files\my app\my app.exe" myArgument1 myArgument2
This way you can setup different shortcuts that each pass different arguments.
Hope this helps.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Thanks!!!
new it was something easy
|
|
|
|
|
Hi folks,
I have a problem concerning a TraceSwitch I'm using in one of my recent projects:
I have a library assembly which is being referenced from a Windows service. Within this library I have several classes, dealing with file searching and parsing. the classes are designed for general use, so I don't write errors from the library in the Event Log. To enable tracing in the library I created a static class with two static members, the switch and the TraceListener (will write to a text file). For the library I created an App.config file withe the following XML code:
<br />
<system.diagnostics><br />
<switches><br />
<add name="ParsingLibTraceSwitch" value="3" /><br />
</switches><br />
</system.diagnostics><br />
The code for the Tracing class is like this:
<br />
namespace ParsingLib<br />
{<br />
public static class Tracing<br />
{<br />
private static TraceSwitch tracer = new TraceSwitch ( "ParsingLibTraceSwitch",<br />
"Enables tracing for the ParsingLib assembly" );<br />
<br />
private static TextWriterTraceListener traceListener = <br />
new TextWriterTraceListener ( "ParsingLib_Trace.txt" );<br />
<br />
public static TraceSwitch Switch<br />
{<br />
get { return tracer; }<br />
}<br />
<br />
public static TraceListener Listener<br />
{<br />
get { return traceListener; }<br />
}<br />
}<br />
}<br />
However, if I run and debug the service, the TraceLevel of the Switch is always TraceLevel.Off.
Does anyone of you have an idea what's wrong with the code? I'm using VS 2005.
Thank you in advance.
|
|
|
|
|
hi
i want to save app setting in registry (for example dataGrid1.AlternatingBackColor)
and this is way that i used for save value to registry :
RegistryKey regkey = Registry.CurrentUser.CreateSubKey(@"SST\Full_SaveSetting\Setting");
regkey.SetValue("Datagrid_AlternatingBackColor",dataGrid1.AlternatingBackColor);
and when i load dataGrid1.AlternatingBackColor from registry as following :
RegistryKey regkey = Registry.CurrentUser.CreateSubKey(@"SST\Full_SaveSetting\Setting");
dataGrid1.AlternatingBackColor=(System.Drawing.Color)regkey.GetValue("Datagrid_AlternatingBackColor");
An unhandled exception of type 'System.InvalidCastException' occurred in it :
Additional information: Specified cast is not valid.
how to cast regkey value to color to solve my problem ????????
|
|
|
|
|
I haven't tested your code but have you tried reading/writting the ARGB value to/from the registy?
It would be something like:
dataGrid1.AlternatingBackColor.ToArgb();
<br />
dataGrid1.AlternatingBackColor = System.Drawing.Color.FromArgb( argbValueGoesHere );
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
hi and thanks ::
but what is the argbValueGoesHere ?
and System.Drawing.Color.FromArgb() get an integer value and when i pass
regkey.GetValue("Datagrid_AlternatingBackColor")
to it don't accept it and when i cast it to int as following :
(int)regkey.GetValue("Datagrid_AlternatingBackColor")
it say me :
Specified cast is not valid.
how to do that ????
|
|
|
|
|
OK, the pointer should have been enough, but this is a sample from your code example:
To write color to the registry:
RegistryKey regkey = Registry.CurrentUser.CreateSubKey(@"SST\Full_SaveSetting\Setting");<br />
regkey.SetValue("Datagrid_AlternatingBackColor", dataGrid1.AlternatingBackColor.ToArgb() );
To read color from the registry:
RegistryKey regkey = Registry.CurrentUser.CreateSubKey(@"SST\Full_SaveSetting\Setting");<br />
dataGrid1.AlternatingBackColor = System.Drawing.Color.FromArgb( (int)regkey.GetValue("Datagrid_AlternatingBackColor") );
Personally, I think that using the registry to store this kind of information is a bad idea, just think, if the user wants to load the app on another machine, these preferences would have to be re-configured on the new machine. There are other ways EG using the app.config file etc.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
How can i remove the left row selection in a DataGrid control using C# ?
M.Gamal
|
|
|
|
|
what's the difference between using the pagesettings property in the PrintDocument.PrintPage event vs the PrintDocument.QueryPageSettings
i know QueryPageSettings is thrown first, but like if you want to change the margins of your new printed page, u can use both events, or not?
thx
grtz
|
|
|
|
|
Hi,
I am trying to execute a method from child form.
MainForm myForm = new MainForm(); // MainForm is the name of the parent form
myForm.refreshLetterBindingSource();
But neither its showing any error, not its executing the method. Can u give me any idea please how to call method in parents Form from Child ?
-- modified at 3:53 Sunday 12th February, 2006
|
|
|
|
|
Dear
u must place code in MainFrom:
ChildForm child=new ChildForm;//in mainForm
child.MdiParent=this;//(this) is yourMainForm
u must place code in ChildForm:
(this.Owner as MainForm).refreshLetterBindingSource();
//cast to MainForm and call method;
if u need anything with .net,mail to me
buccaminh12@yahoo.com
|
|
|
|
|
Hello ,
Thanks a loot for the response. but what if i dont want to make parent form MDI container. Is not it possible to call method in parent form without MDI container declaration ?
Thanks
|
|
|
|
|
Make sure that when the parent form creates the child form, it sets the child form's Owner property to 'this' (this parent form instance).
ChildForm childForm = new ChildForm();
childForm.Owner = this;
childForm.Show();
Then in the child form you simply cast the Owner property to a MainForm and call your method.
MainForm parent = this.Owner as MainForm;
parent.SomeMethod();
The problem with your initial code sample is that it creates a new instance of MainForm, which is not the same instance as the actual parent form.
Josh
|
|
|
|
|
Thanks a loot. Exactly this snippet i was looking for. I will test it and If I face error, I will let u know.
thanks again
Emran
|
|
|
|
|
Thanksssssssssssss a loooooooooooooooooooooot... This snippet was very easy for me to get and exactly what i wanted.
|
|
|
|
|
The principle is exactly the same as Passing Values between Forms in .NET[^], but instead of accessing a property, you access a method instead.
Does this help?
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Looks like accessing data across forms is the most popular question on the C# board.
You'd be a rich man by now if you got a penny everytime you replied with a link to that article
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|