|
By default all controls that you are going to place have a Enable property that will allow user to interact with.
I think your aim is if the optionbutton is cliecked you ned to enable some control(eg: textbox or label).
am i right ?
if so. follow like this
if(radiobutton1.checked)
textboxme.Enabled=false;
else
textboxme.Enabled=true;
here if you click on your radio button it will disable the textbox and if you unchecked it will show the enable the textbox.
And on design time you have to deside what is the startup state of your control.
Sreejith S S Nair
|
|
|
|
|
Thanks... you understand me very well... But could we be more specific: I am using RadioButtonList & textbox. My code is this:
private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (RadioButtonList1.SelectedIndex ==0)
{
RadioButtonList2.Enabled=true ;
textbox1.Enabled = true;
}
else
{
RadioButtonList2.Enabled=false ;
textbox1.Enabled = false;
}
}
I am using ASP.NET Web Application, Visual C# Project. The lunching of Internet Explorer is successful without error in build solution and start. My only problem is my code don't do anything. My code will not enable or disable any RadioButtonList or textbox. By the way my default settings of properties in "RadioButtonList2" in my code is disable and I want my code to enable it once the selectedindex is equal to 0 which is the first option of the user. Thanks and more power to you and to this website!!! chiao!!!
|
|
|
|
|
sorry for this much time.cause i am not feeled well for last two days.
ok.
now i got your problem.
change the AutoPostback property of your first radiolist box control into true.by default it is false.
And then try the above mentioned code.
have a nice day
Sreejith S S Nair
|
|
|
|
|
Good Day!!!
Wonderful.... It works!!! The textbox will enable/disable as I expected!Thank you very much for helping... (Running State)But I jst want to ask if the AutoPostBack will result to refresh effect? I mean each time I change my option to the RadioButtonList the whole web application will download again and will display the new changes made by the user.
One more thing!!! How about the coding of CheckBoxList with 4 to 5 choices with corresponding textbox that will also enable each textbox if the choices are being checked. Here is my coding but it wont work as I expected:
private void checkboxlist1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(checkboxlist1.SelectedIndex == 0)
{
textbox1.Enabled = true;
}
if(checkboxlist1.SelectedIndex == 1)
{
textbox2.Enabled = true;
}
if(checkboxlist1.SelectedIndex == 2)
{
textbox3.Enabled = true;
}
if(checkboxlist1.SelectedIndex == 3)
{
textbox4.Enabled = true;
}
}
If I checked the first choice it will enable the textbox1 ang when I checked also the second choice the textbox2 will not enable, so on and so on to the other choices. The program will allow me to checked all the choices but will not enable all the corresponding texbox of each choices.
Hope you could help me figure out whats wrong with my program....
Thanks and God Bless!!!
|
|
|
|
|
Sure it will work.Write down your code on valuechange event. and try your all requirement.
if you feel any uncomfortable please let me know that.
Sreejith S S Nair
|
|
|
|
|
don't think like this. if you got a little idea that HOW ? you have to develop the remaining.
dear please use little logic and refer MSDN. This forum is for help only not for coding support.ok
try
this
if(CheckBoxList1.SelectedItem.Value.ToString()=="c1")
TextBox1.Enabled=false;
else
TextBox1.Enabled=true;
if(CheckBoxList1.SelectedItem.Value.ToString()=="c2")
TextBox2.Enabled=false;
else
TextBox2.Enabled=true;
if(CheckBoxList1.SelectedItem.Value.ToString()=="c3")
TextBox3.Enabled=false;
else
TextBox3.Enabled=true;
if(CheckBoxList1.SelectedItem.Value.ToString()=="c4")
TextBox4.Enabled=false;
else
TextBox4.Enabled=true;
if(CheckBoxList1.SelectedItem.Value.ToString()=="c5")
TextBox5.Enabled=false;
else
TextBox5.Enabled=true;
if(CheckBoxList1.SelectedItem.Value.ToString()=="c6")
TextBox6.Enabled=false;
else
TextBox6.Enabled=true;
Sreejith S S Nair
|
|
|
|
|
Heyas all,
Really trying my hardest to take all this information in. I come from a unix C environment and I'm finding the OO paradigm very aawkward so far, but I'm gonna keep it. My question is, If say I have a label on a form, and on a second form, I have a button that when clicked will populate the label with the text in a textbox from the first form. basically how do go about making the objects on a seperate form available from within another form. That sounds really confusing. I hope someone understands what I trying to say.
P.S. - Yes, English is my first language
kha0s
"There are 10 types of people in this world; Those that know binary and those that do not."
|
|
|
|
|
Each form you create in .net is in itself a class so if you instantiate an object of one form within the code behind for the other form you will be able to access it's components ie:
Within the Form2 code write
Form1 myForm1 = new Form1();
Then also within the Form2 code write
textboxname.DataSource = myForm1.Text.ToString();
and it should put the data in the approppriate place
Please not what I have written is very basic there is a large amount of help for questions like yours in places like this website and msdn so don't be shy dig right in an get an early understanding of OOP with .net
|
|
|
|
|
Why are you calling Text.ToString() ? The Text property is already a String . Calling ToString() is a waste.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You need to pass an instance of the first form to your second form. For example:
public class Form1 : Form
{
internal Label label1;
private Button button1;
public Form1()
{
label = new Label();
button1 = new Button();
button1.Click += new EventHandler(button1_Click);
}
private void button1_Click(object sender, EventArgs e)
{
using (Form2 form = new Form2(this))
form.ShowDialog(this);
}
}
public class Form2 : Form
{
private TextBox textBox1;
private Button button1;
private Form1 form;
public Form2(Form1 form)
{
this.form = form;
textBox1 = new TextBox();
button1 = new Button();
button1.Click += new EventHandler(button1_Click);
}
private void button1_Click(object sender, EventArgs e)
{
if (form != null) form.Label.Text = textBox1.Text;
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I need to add bitmaps to some buttons, but they are tiny bit maps. Whats the best way to create these small buttons so the small bitmaps complete cover the button ?
|
|
|
|
|
Draw them yourself. Override OnPaint and use PaintEventArgs.Graphics to draw the Bitmap s using Graphics.DrawImage . Give it the bounding rectangle of the Button and the image will be stretched.
You could also try searching CodeProject. I know I've seen several articles covering this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
First off thanks for the response. I have tried searching botht the artciles and messageboad but I cannot find anything on point.
I think I understand what you mean, but i'm not sure if that will give me what I want. I'd like to fit the button to the picture, not stretch the picture to the button. Is your solution still the same ?
I assume I will need to inherit the Button Class and create my own control in order to override the OnPaint() method ?
I've tried to create the buttons and fit to the picture using the code below, but for some reason the bottom of the picture is getting chopped off, or at least it appears to be.
Image ButtonPic = null;
Stream ImgStream=null;
int ImageHeight,ImageWidth,ButtonY,ButtonX=0;
ImgStream = this.GetType().Assembly.GetManifestResourceStream("MiniP3.PlayerPrevious.bmp");
ButtonPic = Image.FromStream(ImgStream);
btPrevious = new Button();
btPrevious.Image=ButtonPic;
btPrevious.Size = ButtonPic.Size;
btPrevious.ImageAlign=ContentAlignment.MiddleCenter;
ImageHeight = ButtonPic.Height;
ImageWidth = ButtonPic.Width;
ButtonY = (int)(pnButtons.Height-ImageHeight)/2;
btPrevious.Location = new Point(ButtonX,ButtonY);
this.btPrevious.Click += new System.EventHandler(this.PreviousClick);
pnButtons.Controls.Add(btPrevious);
|
|
|
|
|
Yes, the best way is to extend the Button class with your own. This makes it easy to add new image buttons as the derivative class encapsulates the code necessary to display an image.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I just found Marc Clifton's Article.
|
|
|
|
|
Hello All, I have an ASP.net application that is currently using the push method and displaying reports off of ADO.net datasets. I am struggling with a design method for the following questions:
1. .NET treats each crystal report you add to your project as a class and I am using a several reports and the ReportDocument class to set datasources for each one and so on. Depending on which report my users select in an aspx page i show them the report they want by creating an object of the type of report they selected. I am wondering if I can create say Object myobj = new Object() and depending on what report they select cast the general myobj object into the specific type of the report class the user selected instead of having to instantiate an instance of every type of report within my code?
Thanks for your help
Frank
|
|
|
|
|
Depending on how you display the list of reports, you can use Activator.CreateInstance to create an instance of the report. Cast that to the ReportDocument base class and call SetDataSource with your ADO.NET DataSet .
For instance, if you use a ListBox you could set the display name to whatever you want, but set the value for each item to the corresponding .rpt name. Since this gets compiled to a class with the same name using a namespace that is your project's root namespace (the project name by default) plus any folders it's in, you could do something like this:
string reportName = "MyWebApp.Reports." + listBox1.SelectedValue;
ReportDocument report = Activator.CreateInstance(reportName, "MyWebApp.dll");
report.SetDataSource(dataSet1); Of course, you should add error handling like try-catch blocks and conditionals (like checking for null values, etc., since throwing exceptions is expensive).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is there any way to add a menu item to an existing drop down menu in Excel using the Visual Studio Tools for Microsoft Office 2003? I want to add a menu item to the drop down list you get when you right click on a cell on the worksheet. I also want to add an event handler for that new menu item.
Thanks for any help
Mike.
|
|
|
|
|
Hi,
I am getting an "its inaccessabile due to its protection level" error
here's my code:
<br />
public DataSet dsDiff; <- defined globally <br />
<br />
dsDiff.WriteXml(spath + @"\MidnightData.xml", XmlWriteMode.DiffGram);<br />
<br />
<br />
Any Ideas ?
Thanks,
JJ
|
|
|
|
|
Yes, but the class that it's defined in is either sealed or private or internal or something else.
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
|
|
|
|
|
"Global" variables don't exist in C# or the .NET CLI. You also might want to cut and paste the exact error message since the one you typed isn't spelled correctly.
There might be a accessor problem with the DataSet or there could be a security issue with the path that your writing data to. We'll need the exact Exception message to find out.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Dave,
It was because I was using the wrong method argument for the dataset. I had it using a string sFilename when in order to use the XmlMode.Diffgram I needed to supply a XmlWriter object instead. So as soon as I supplied it the proper method arguments all was well.
Weird error message though !
<br />
public void WriteXml(<br />
XmlWriter writer,<br />
XmlWriteMode mode<br />
);<br />
<br />
Thanks,
JJ
|
|
|
|
|
Globel variable doesn't exist in C#. that is true. But if you want to access a variable Globally. what you will do ?
i have clear idea that how i can use a variable globally in C#. app.config
" dear friend you forgot this ".
Sreejith S S Nair
|
|
|
|
|
Globel variable doesn't exist in C#. that is true. But if you want to access a variable Globally. what you will do ?
i have clear idea that how i can use a variable globally in C#. app.config
" dear friend you forgot this ".
Sreejith S S Nair
|
|
|
|
|
Does anybody know if a c# program can run in 64 bit mode on Windows XP 64bit edition or Windows server 2003 64bit. I have some customers that have AMD Athlon 64 and asking me!
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|