|
I'm using visual c# 2005 and would like to know if there is an easier way to process alot, about 35, checkboxes. Could you put the controls in an array or would you just have to process each one manually??
|
|
|
|
|
tom_dx wrote:
Could you put the controls in an array or would you just have to process each one manually??
Yes, put them in an array.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
How though I'm new to C# and I have never seen arrays contains any controls, can you show an example?
|
|
|
|
|
It is just like an array holding anything else. However there is a specialised class for holding Controls. See MSDN: ControlCollection[^]
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
In one application where I had a lot of checkboxes, I put them into a list view control. You can advise the ListViewControl to have checkboxes left to each item.
Another solution would be to use reflection and a for loop, if your CheckBoxes are labeled with a running number like MyCheckBox1 , MyCheckBox2 , etc.
--
Affordable Windows-based CMS: www.zeta-producer.de/enu
|
|
|
|
|
i got it!
i did the following..
CheckBox[] checkboxes = new CheckBox[35]
|
|
|
|
|
Hello,
I have a form with a variable. I want to be able to send this variable to another form.
Example: i have a customer form and want to send the customer number to the update customer form. So when l click update customer the update customer form will receive the customer number from the customer form.
Hope you understand this.
Many thanks in advance,
Steve
|
|
|
|
|
As we covered in this forum many times before, it all comes down to references. In order to even set a property on the second form, your first form needs a reference to it. So, assuming the first form is the initial form (upon which, perhaps, a button click opens the second form), you need to either keep an instance of the second form or pass an instance of the first form to the second. An example of the latter follows:
class Form1 : Form
{
Button openForm2;
TextBox customer;
public Form1()
{
openForm2 = new Button();
Controls.Add(openForm2);
openForm2.Click += new EventHandler(openForm2_Click);
customer = new TextBox();
Controls.Add(customer);
}
void openForm2_Click(object sender, EventArgs e)
{
using (Form2 form = new Form2(this))
form.ShowDialog(this);
}
public string Customer
{
get { return customer.Text; }
set { customer.Text = value; }
}
}
class Form2 : Form
{
Form1 parent;
public Form2(Form1 form)
{
parent = form;
}
} This is really part of the basics of object-oriented design (OOD). You might consider picking up a book on OOD or studying many of the fine articles on this site about OOD.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi
how i can draw a control on somewhere (on a form say)
but NOTE that not placing the control on the form, Drawing
the form on it.
i want to draw a control 100 times on different palaces of
a form to seem that i have 100 controls on form.
i know that they are not controls and are the drawing of
a control.
|
|
|
|
|
Read the documentation for Control.OnPaint (inheritted by all controls). You override this method and use the Graphics property of the PaintEventArgs passed to it. Be sure to read the documentation for the Graphics class.
For example, to draw a rectangle just slightly smaller than the bounding rectangle for a control (remember that Form derives from Control , and thus inherits all its properties, methods, fields, and events (members)):
class Form1 : Form
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle rect = Bounds.Inflace(-5, -5);
e.Graphics.DrawRectangle(Pens.Black, rect);
}
} For more examples, search this site for "owner drawing" in the C# and .NET categories. There are many articles about this topics on this developer site.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
This is a big question, but how do you architect your application to centrally manage memory allocation/deallocation? To approve or deny allocation request from its child threads?
For instance, you can configure upper/lower memory limits for SQL Server. This implies a centrally managed memory allocation. Has anyone done this before? How's this done? References would be helpful.
Norman Fung
|
|
|
|
|
|
Anything, actually, Java, C++, C#, whatever. Just a question in general, I didn't run into any problem in specific actually.
Norman Fung
|
|
|
|
|
Well it all starts with asking the OS for memory with malloc() and friends.... i'm not clear what you really mean. Your program has to fit into memory, its up to you how you deal with that. Perhaps reading stuff on GC's (see boehm opensource), and C++'s autopointers.
You mentioned SQL. Those options are just for tuning SQL performance, eg the # and size of indices that are kept in memory cache etc etc.
There was a link to an article on memory management too on www.osnews.com the last week, I havent read it yet though.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Hello,
I am using Tri-state tree veiw (http://www.codeproject.com/cs/miscctrl/TriStateTreeViewSubmissio.asp) to make a small application.
When I add images to the treeview node, it get added to all nodes, but I do not want it in the root node.
Can anyone one guide how to remove the image from root node?
Even if I change the Imageindex and Selected InageIndex property to such a number that is not in the image list (say I have image 1, 2, and 3; and I make the Index Property =4) I can remove the image but not able to shift the node text towords left side, such that it should fill up the blank space of image. If some how i can shift the node text near to the node , that will do the job.
please guide
regards
|
|
|
|
|
Hi All,
I am converting a VB6 app to C# and have come across something that has raised a question.
What I want to do is to create a structure, populate the values for each member in the structure and write it to a file. I used to do this in a Binary access mode in VB6. This produced a file with no quotes around the text in the structure (in VB6 it is a type) and then I would write out a newline. I cannot find how to do this in C#. Structures I have found and that is fine, but writing the structure to a file so that the file has no quotes or other characters seperating the data has not been frutiful.
Can anyone point me into the right direction?
Thanks
Stephen
|
|
|
|
|
Here is a quick example:
using System;
using System.IO;
public class test
{
[STAThread]
public static void Main()
{
test t = new test();
t.Write();
}
private void Write()
{
using(StreamWriter sw = new StreamWriter(@"C:\test.txt"))
{
sw.WriteLine("Hello Nick");
}
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks Nick.
|
|
|
|
|
HI.
I have a question regarding Datagrid and its Templatecolumn.
I am trying to populate a crosstab query result in to a Datagrid. That works fine. Now I want to add hyperlinks to all the populated values in the Datagrid.
I want to pass (1) a Id (2) column-name of that fieldvalue displayed as querystring. So my idea is to pass two values in the query string.
Hyperlink column only allows one value in the querystring.
Read lot of articles about Templatecolumn.
I don’t know how to build the Templatecolumn dynamically and how to pass two values as querystring.
Please help me in solving this problem.
HOpe you all understand my problem.
|
|
|
|
|
Your question belongs in the ASP.NET forum, since only the ASP.NET DataGrid has a TemplateColumn . Please use the forum most appropriate for your questions.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I am having some trouble with this method that I want converted into c#, and being a c# novice it is taking me far longer than I would like.
At the moment it is written in c++ and its function is to set the DeviceGammaRamp given a certain int value (igamma).
Here it is...
void AdjustGamma( int iGamma )
{
HDC hDC = GetDC(GetDesktopWindow());
bool bMinus = iGamma < 0;
if( bMinus )
iGamma = -iGamma;
iGamma = min(max(iGamma, 0), 255);
if( hDC ) {
const int iNum = 256;
struct sRamp {
WORD wRed[iNum];
WORD wGreen[iNum];
WORD wBlue[iNum];
} wRamp;
if( GetDeviceGammaRamp(hDC, (LPVOID)&wRamp) ) {
for( int i = 0; i < iNum; i++ ) {
if( bMinus ) {
wRamp.wRed[i] = (255 - iGamma)*(i);
wRamp.wGreen[i] = (255 - iGamma)*(i);
wRamp.wBlue[i] = (255 - iGamma)*(i);
} else {
wRamp.wRed[i] = 65535 - (255 - iGamma)*(255 - i);
wRamp.wGreen[i] = 65535 - (255 - iGamma)*(255 - i);
wRamp.wBlue[i] = 65535 - (255 - iGamma)*(255 - i);
}
}
BOOL bRet = SetDeviceGammaRamp(hDC, (LPVOID)&wRamp);
}
ReleaseDC(GetDesktopWindow(), hDC);
}
}
There is some additional information as well, I have imported gdi32.dll sucessfully, and it looks like this...
[DllImport("gdi32.dll")]
private static extern bool SetDeviceGammaRamp(IntPtr hDC, IntPtr lpRamp);
If somebody could help me with this method then I could most certainly finish of another two that I have incompleted.
Thanks for your time
|
|
|
|
|
You may want to have a look at this[^] article by Christian Graus. The source code has an implementation of gamma correction written in C#.
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
Thanks! That was an awesome article! It really has helped me alot! I might consider implementing some other features in my program now!
Wow I'm so happy now!
|
|
|
|
|
SeaMonkey007 wrote:
That was an awesome article!
Yep! Christian is a God!
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|