|
Just need a logic as follows.
if( !checkBox2.Enabled )
checkBox2.Enabled = true;
else
checkBox2.Enabled = false;
Hope it is fine, and sorry for disturbing.
Thanks for all replay
I appreciate your help all the time...
Eranga
|
|
|
|
|
The statement checkBox2.Enabled ^= true does the same thing.
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
Hi,
you want Checkbox.EnabledChanged event
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
checkBox2.Enabled = this.checkbox1.Enable;
}
Never trouble trouble until trouble troubles you.
|
|
|
|
|
Hi all,
On a specified registry(actually on a sub key of the registry), I want to copy all there settings to a file. And later I want to restore that file setting too. How can I do that.
Thanks
I appreciate your help all the time...
Eranga
|
|
|
|
|
1) Right click te key and click export.
2) To restore double click the file you exported before.
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
Yes, its true
But I want to do it through my code. When a user click a button I want to make a backup and so on
I appreciate your help all the time...
Eranga
|
|
|
|
|
use Microsoft.Win32.Registry and get the root RegistryKey which you want to backup. having this, loop recursibly over registryKey.GetSubKeyNames and get the corresponding values. now you can store this as xml.
|
|
|
|
|
|
|
Hello Everybody,
I have developed an application in which i have used Code 39 font and Embedded that in my application now whenever i run that application on XP that runs and give specified output.
Now when i tested it on Vista than i am unable to get the output in Code 39 font its just give output in normal font.
|
|
|
|
|
I haven't got a Vista box here at work to test on but it could depend on how you're getting the font. This is the method I use...
[DllImport("gdi32.dll")]
private static extern IntPtr AddFontMemResourceEx(
byte[] pbFont, int cbFont, IntPtr pdv, out uint pcFonts);
public Font GetEmbeddedFont(string name, float size)
{
PrivateFontCollection pfc = null;
Font fn = null;
if (null == pfc)
{
Stream stmFont = Assembly.GetExecutingAssembly().GetManifestResourceStream(
MethodBase.GetCurrentMethod().DeclaringType.Namespace + ".Resources." + name);
if (null != stmFont)
{
byte[] rgbyt = new Byte[stmFont.Length];
stmFont.Read(rgbyt, 0, rgbyt.Length);
uint cFonts;
AddFontMemResourceEx(
rgbyt, rgbyt.Length, IntPtr.Zero, out cFonts);
IntPtr pbyt = Marshal.AllocCoTaskMem(rgbyt.Length);
if (null != pbyt)
{
Marshal.Copy(rgbyt, 0, pbyt, rgbyt.Length);
pfc = new PrivateFontCollection();
pfc.AddMemoryFont(pbyt, rgbyt.Length);
Marshal.FreeCoTaskMem(pbyt);
}
}
}
if (null != pfc)
{
if (pfc.Families.Length > 0)
{
fn = new Font(pfc.Families[0], size);
}
}
return fn;
}
Then something like
label1.Font = GetEmbeddedFont("FRE3OF9X.TTF", 30);
If it doesn't work I'll have a play on Vista at home tonight.
Edit: Have tested the code above and it works fine on Vista
Needs the following 'usings'
using System;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
Dave
modified on Monday, March 3, 2008 11:50 AM
|
|
|
|
|
Hello Sir,
I have tried the solution that u gave me but it is not working ....
Before using your solution i was using this one....
class PrivateFonts
{
[DllImport("Gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, int cbFont, int pdv, ref int pcFonts);
public System.Drawing.Text.PrivateFontCollection GetFont(string[] FontResource)
{
//Get the namespace of the application
string NameSpc = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString();
System.IO.Stream FntStrm;
System.Drawing.Text.PrivateFontCollection FntNc = new System.Drawing.Text.PrivateFontCollection();
int i;
for (i = 0; i <= FontResource.GetUpperBound(0); i++)
{
//Get the resource stream area where the font is located
FntStrm = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpc + "." + FontResource[i]);
//Load the font off the stream into a byte array
byte[] ByteStrm = new byte[(int)FntStrm.Length + 1];
FntStrm.Read(ByteStrm, 0, Convert.ToInt32((int)FntStrm.Length));
//Allocate some memory on the global heap
IntPtr FntPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(typeof(byte)) * ByteStrm.Length);
//Copy the byte array holding the font into the allocated memory.
System.Runtime.InteropServices.Marshal.Copy(ByteStrm, 0, FntPtr, ByteStrm.Length);
//Add the font to the PrivateFontCollection
FntNc.AddMemoryFont(FntPtr, ByteStrm.Length);
Int32 pcFonts;
pcFonts = 1;
AddFontMemResourceEx(FntPtr, ByteStrm.Length, 0, ref pcFonts);
//Free the memory
System.Runtime.InteropServices.Marshal.FreeHGlobal(FntPtr);
}
return FntNc;
}
}
<b>ON BUTTON CLICK</b>
//string[] fontNames = { "FRE3OF9X.TTF" };
//PrivateFonts privateFonts = new PrivateFonts();
//System.Drawing.Text.PrivateFontCollection FntNc = privateFonts.GetFont(fontNames);
//labelBarcode.Font = new Font(FntNc.Families[0], 12);
Can you tell me what modification i have to do to get this work on Vista
because its working nice on XP....
Thanks
|
|
|
|
|
I don't know why the code I supplied doesn't work for you - I thoroughly tested it on XP and Vista.
Anyway, your code has two problem lines (I'm not sure how you got it to work in XP!):
FntStrm = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpc + "." + FontResource[i]);
won't work as the font is stored in 'yournamespace'.Resources... so you should try
FntStrm = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpc + ".Resources." + FontResource[i]);
byte[] ByteStrm = new byte[(int)FntStrm.Length + 1];
Why the +1? Remove that and it'll work.
byte[] ByteStrm = new byte[(int)FntStrm.Length];
Dave
modified on Saturday, March 1, 2008 5:06 AM
|
|
|
|
|
Thanks sir,
For a such wounder full solution
I will try it.
Thanks
Dikshant
|
|
|
|
|
string NameSpc = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString();
I've just noticed the unnecccesary .ToString() on this line. It'll work with or without it, but the Name property is already a string so there's no need.
Dave
|
|
|
|
|
I want to color specific rows of the datagrid of windows application in C#.net 1.1 on the basis of data in it. Please help me.
Arijit Banerjee
|
|
|
|
|
If(Condition)
{
dataGridView1.Rows[1].DefaultCellStyle.BackColor = Color.Red;
}
else
{
dataGridView1.Rows[1].DefaultCellStyle.BackColor = Color.Blue;
}
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
It is not for web application. I am in windows application in .Net1.1 there is no Rows property.
Arijit Banerjee
|
|
|
|
|
Hello, I am very very new in this field, and my boss ordered me to develop a program which reads from textboxes of other softwares and stores the data.
Now I know that windows handler will do that, but field to develop a strategy how to do that.
Any suggestion Please?
----------------
Homeopathically Yours
|
|
|
|
|
I think it will me more easy in C++
any how at first you have to get the window handler of the other application and than from that handler get the handler of other controls on the window.
|
|
|
|
|
hello friends,
i have some values displayed in a comboBox. the selected value is stored in a variable. now the logic is this that when a button is pressed, the saved value of the combo Box is to be displayed in the combo Box. how do i accomplish this?
i have tried adding the value through the 'Items' property. it adds the value into the combolist but doesn't display it directly.
reply soon plz.
Saira
|
|
|
|
|
You can simply say
comboBox.SelectedValue = Value; / comboBox.Value (in case it is a windows form)
(Assuming the value was already in the list)
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
use SelectedValue property
|
|
|
|
|
Hi,
How apply comman Scrollbar for Two Treview control in C#
Please Replay me Asoon as possible
Thanks
|
|
|
|