|
You said you were looking for a way to find all controls within your form..
Anyway, d@nish gave you an answer to this.
|
|
|
|
|
Is Google not working for you?
I have shocking news: MenuItem and ToolStripMenuItem inherit from System.ComponentModel.Component , not from System.Windows.Forms.Control , so they aren't Controls.
Obviously all menu items do reside in some hierarchical data structure, such as MainMenu.MenuItems and MenuStrip.Items
|
|
|
|
|
this code cal get all control in the form.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GetAllControls
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
findControl(this);
foreach (Control control in controlList)
{
if (control is System.Windows.Forms.Panel)
{
}
}
}
private void findControl(Control control)
{
if (control != null && control.Controls != null)
{
foreach (Control childControl in control.Controls)
{
findControl(childControl);
this.controlList.Add(childControl);
}
}
}
private List<Control> controlList = new List<Control>();
}
}
|
|
|
|
|
Hi Everybody,
I want to learn, How to remove particular character from the string.
Example: -
1) "A+B+C" <<== i want to remove "+" plus character
2) "A B C" <<== i want to remove "Spaces"
Thank you in advance and appreciate for each replying
(Riaz)
|
|
|
|
|
use this
.Replace("+", String.Empty);
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
|
string str="A+B+C";
str=str.Replace("+"," ");
str=str.Replace(" ","");
|
|
|
|
|
Hello,
I just posted a similar question before this one, but still it is a different question so posting as a separate thread.
I have added the following line in my AssemblyInfo.cs
[assembly: InternalsVisibleTo("UI Test")]
I did this to allow my test project access this assembly's internal method for testing. But I dont want to keep it accessible like this in my production (Release) build. At this moment, I am just commenting this line for production build and commenting out for debug mode, but it is really a hassel. Is there any other automatic way available for doing so ? Can I add this asselbly attribute programmatically by detecting if it is DEBUG mode or RUN mode ? Will that cost high performance ?
|
|
|
|
|
Maybe this can help you.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Yes. Just enclose it in:
#if (DEBUG)
. . .
#endif /ravi
|
|
|
|
|
Hi Ravi,
Thank you Soooooooooo much for this snippet. It just saved me.
|
|
|
|
|
You're welcome!
/ravi
|
|
|
|
|
Hello everyone,
I am just thinking if it is possible to execute a block of code conditionally based on DEBUG Mode / RELEASE Mode ?
For example, I have a code block like this:
var x = 5;
var y = 0;
var z = x / 5;
Now, I want that my application should throw exception only if it is DEBUG mode so that I can be notified any possible exception when I am developing my Windows Application. But when I will ship my application to my customer, I dont want
that the customer get the Exception, so, for my production version or RELEASE mode, I want the block to be like this,
try
{
var x = 5;
var y = 0;
var z = x / 5;
}
catch
{
}
Now, Is it possible to do so ? I know there are some #pragma directive to execute code conditionally, but I dont know
if it is possible to detect DEBUG / RELEASE mode from my #pragma directive code, any idea please ?
|
|
|
|
|
Use this -
#if (DEBUG)
#else
...
#endif
|
|
|
|
|
Dear friends,
What is the Equivalent for java property file .net???
and how to use that???
any idea? link?
by
Joe
|
|
|
|
|
Probably the nearest equivalent is an application configuration file. Google for "c# application configuration file" and you will get about a zillion matches.
|
|
|
|
|
hi,
can i add some text or control to row headers and hw to do it?
|
|
|
|
|
Which control's row header are you speaking of?
|
|
|
|
|
row headers of datagridview?specifically row header of first row i.e header row?
|
|
|
|
|
You can set the text like this:
dataGridView.Rows[rowIndex].HeaderCell.Value = "Some value";
|
|
|
|
|
i want to add a control programatically to topleftheadercell but i m unable to do so.any idea?
|
|
|
|
|
AFAIK, there is no direct way of adding controls to that cell. You will have to Paint a control yourself within the region of that cell.
|
|
|
|
|
|
does object class implements IDisposable interface.
|
|
|
|
|