am i the only one who thinks that c# screen development really sucks? i have just completed the silly task of repeating the same 30 lines of code sixteen times.

and why, some might ask, are you so silly to do that? it is because, unlike java and visual basic 6.0, c# has no damn way of creating control arrays. so where you could just have written some generic function and just pass it an argument or use some for control loop you have to repeat the same sud forsaken code for each and every single textbox which does the exact same thing.

how to create a calender control by using a imahe button in the html control by using java script

Ravenous Wolf,

Can you provide a sample of the code (your repeated 16 lines segments ). Yes you can create control arrays. If you find yourself typing the same 16 or so lines for multiple controls, it begs for a method to perform that action. Give us some code that shows what you are trying to do, and I will try to show you a better way.

--Jerry

how to create a calender control by using a imahe button in the html control by using java script

How to create a new thread for a question that is unrelated to the question the original poster is asking.

here it is. i have, for sake of sanity, included only three.

//get the first group box
            x++;
            sLabel = Convert.ToString(x) + " %%$";

            if (txtCompany1.Text != "" && txtCompany1.Text != null)
            {
                s1 = txtCompany1.Text;
                sLabel = sLabel + s1 + "%%$";
            }

            s1 = "Attn " + cboTitle1.Text;
            
            if (txtName1.Text != "" && txtName1.Text != null)
                s1 = s1 + " " + txtName1.Text;
            
            if ( txtSurname1.Text != "" && txtSurname1.Text != null )
                s1 = s1 + " " + txtSurname1.Text;

            s1 = s1 + "%%$";

            if (txt1Add1.Text != "" && txt1Add1.Text != null)
            {
                s1 = txt1Add1.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (txt2Add1.Text != "" && txt2Add1.Text != null)
            {
                s1 = txt2Add1.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (txtCity1.Text != "" && txtCity1.Text != null)
            {
                s1 = txtCity1.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (txtCode1.Text != "" && txtCode1.Text != null)
            {
                s1 = txtCode1.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (sLabel != "")
            {
                al.Add(sLabel);
                sLabel = "";
                s1 = "";
            }

//get the second group box
            x++;
            sLabel = Convert.ToString(x) + " %%$";

            if (txtCompany2.Text != "" && txtCompany2.Text != null)
            {
                s1 = txtCompany2.Text;
                sLabel = sLabel + s1 + "%%$";
            }

            s1 = "Attn " + cboTitle2.Text;

            if (txtName2.Text != "" && txtName2.Text != null)
                s1 = s1 + " " + txtName2.Text;

            if (txtSurname2.Text != "" && txtSurname2.Text != null)
                s1 = s1 + " " + txtSurname2.Text;

            s1 = s1 + "%%$";

            if (txt1Add2.Text != "" && txt1Add2.Text != null)
            {
                s1 = txt1Add2.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (txt2Add2.Text != "" && txt2Add2.Text != null)
            {
                s1 = txt2Add2.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (txtCity2.Text != "" && txtCity2.Text != null)
            {
                s1 = txtCity2.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (txtCode2.Text != "" && txtCode2.Text != null)
            {
                s1 = txtCode2.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (sLabel != "")
            {
                al.Add(sLabel);
                sLabel = "";
                s1 = "";
            }

 //get the third group box
            x++;
            sLabel = Convert.ToString(x) + " %%$";

            if (txtCompany3.Text != "" && txtCompany3.Text != null)
            {
                s1 = txtCompany3.Text;
                sLabel = sLabel + s1 + "%%$";
            }

            s1 = "Attn " + cboTitle3.Text;

            if (txtName3.Text != "" && txtName3.Text != null)
                s1 = s1 + " " + txtName3.Text;

            if (txtSurname3.Text != "" && txtSurname3.Text != null)
                s1 = s1 + " " + txtSurname3.Text;

            s1 = s1 + "%%$";

            if (txt1Add3.Text != "" && txt1Add3.Text != null)
            {
                s1 = txt1Add3.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (txt2Add3.Text != "" && txt2Add3.Text != null)
            {
                s1 = txt2Add3.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (txtCity3.Text != "" && txtCity3.Text != null)
            {
                s1 = txtCity3.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (txtCode3.Text != "" && txtCode3.Text != null)
            {
                s1 = txtCode3.Text + "%%$";
                sLabel = sLabel + s1;
            }

            if (sLabel != "")
            {
                al.Add(sLabel);
                sLabel = "";
                s1 = "";
            }

I am trying to accomplish the Same thing. See thread (Pass ObjectWith Index ForNext)

I am trying to update 64 bit displays in a For Next Loop.
I can pass One Object successfully but can't iterate through a collection in order.
Shouldn't GetNextControl do this?
It Retrieves the next control forward or back in the tab order of child controls.
I can't get this to work either. Is there a Better method to do this?

fn70DiscreteIO statusIO = new fn70DiscreteIO();
for (int i = 0; i <= 64; i++)
{
UpdateIO(statusIO.DiscreteValue, i, 
GroupBox.GetNextControl(System.Windows.Forms.ProgressBar ctrl, bool forward)); 
}

private void UpdateIO(int data, int bit, System.Windows.Forms.ProgressBar textControl)
{
if ((data & (1 << bit)) != 0)
{
textControl.Value = 1;
}
else
{
textControl.Value = 0;
}
}

I'm new to C#, but it seems to me that surely you'd be able to pass those objects as reference parameters so that changes in your method can reflect on the original object where it is needed. I remember coming across a ref keyword?

Regardless, I think you're code is a bit flawed. Consider:

if (txtCompany1.Text != "" && txtCompany1.Text != null) ...

If indeed txtCompany1.Text was equal to null then perhaps the comparision txtCompany1.Text != "" will produce an Exception; but then this isn't really Java hey - in Java we use a method of the String object to test equailty and thus the object must first exist. I think the usual way to do this is to do the 'null' test first then so that if it is indeed false the rest of the and expression is ignored. On that note, I think that the Text property of a textbox is never null :?: Does anyone know if that is ineed the case? Was just wondering :icon_smile: Oh and yeah maybe ref could help with your problem?

The ref method parameter keyword on a method parameter causes a method to refer to the same variable that was passed into the method. Any changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method.

This was taken from the msdn site. Hmmm but after looking at your code again perhaps you don't need to use ref :icon_cheesygrin: I still don't see why parameter passing won't work though :?:

This might help you. Also the GetReference should work I just don't know the exact usage.

void FunctionSupplyingControl(){
Control ctrl;
FunctionConsumingControl(ctrl);
for (int i = 1; i < 64; i++){
ctrl = GetNextControl(ctrl, forward);
FunctionConsumingControl(ctrl);}}
void FunctionConsumingControl(Control ctrl){}
for (int i = 0; i <= 7; i++) 
{
String strControl = "IX" + i;
Object Ctrl = GetReference(strControl);
Ctrl.Value = MyValue;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.