DdoubleD 315 Posting Shark

Is it possible you have subreports in your report that have missing parameter links?

Try adding the following code statement and see if it shows any unforeseen parameters:

foreach (ParameterFieldDefinition parafld in wordReport.DataDefinition.ParameterFields)
            {
            }// set breakpoint and examine parafld
DdoubleD 315 Posting Shark

Not sure if you noticed a thread in here created 2008/01 that was posted to today. It contained an interesting link about automating word in c# and I wanted to pass it on to you: How to automate Microsoft Word to create a new document by using Visual C#

DdoubleD 315 Posting Shark

Anytime. Please mark the thread as solved.

DdoubleD 315 Posting Shark

Yes, how would I check for the version information inside of the application itself? And when the application finds an updated version, it will update itself.

String strVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

The version information it obtains is setup inside: AssemblyInfo.cs

DdoubleD 315 Posting Shark

Are you asking how to check for version information? If so, are you asking how to check it inside the application, or inside the setup/install?

DdoubleD 315 Posting Shark

If the controls are not available from the Tools tab in the IDE, then they are not installed and you would have to:

1) find custom controls already written and available for free: Custom Slider Controls, or
2) buy a third-party toolkit containing custom controls, or
3) write/create them yourself

I would suggest pursuing option #1 to start because there are many contributions available; checking out option #2 just to see what is being marketed; then proceeding to #3 if necessary or that suits you.

Please mark this as solved if your question is answered--thanks.:)

DdoubleD 315 Posting Shark

Be sure to use code tags because it makes it easier to read the code.

You are not passing in any parameters to the report in the code you gave. What are the names of the parameters defined in the report and what are their types?

DdoubleD 315 Posting Shark

Here is a decent link to Fun with Prime Numbers. I went ahead and converted the "The Array Method (Sieve of Eratosthenes)" code section to C# just for fun and to make sure it worked. Anyway, the article explains different approaches to finding primes--give it a shot then check back for help.

DdoubleD 315 Posting Shark

I have a message Box with two options, Retry or Cancel. Upon clicking cancel, I want to close the MessageBox and then load the main Form. Any idea how to do that? This function is already within a button_click function and I want to get out of this function and back to the Form_load.

void button_click(...)
{

dr=MessageBox.Show(.....);
if(dr== DialogResult.Cancel)
//exit the button and go back to the main form

}

The MessageBox call works fine in the Form_Load method. If you are wanting to cancel that form's creation at that point to return to the calling form (main form?), you can call Close() method after checking DialogResult.Cancel .

DdoubleD 315 Posting Shark

FYI: You can set the Tag property to your table for each treenode without having to use an owner drawn control. Are you planning to drag/drop from one TreeView to another?

DdoubleD 315 Posting Shark

I agree on that but, what I would like to add is, that you will never reach this bit:

available.Add(history[history.Count - 1]);
history.RemoveAt(history.Count - 1);

because you call your recursion function before these two lines are executed. So in order to fix this, you need to call your recursion function after the lines.

That's funny, because I stepped over those lines several times in the debugger. I'd like to hear exactly what it is that is trying to be achieved in this method because I'm not convinced those last two lines need to be there at all.

DdoubleD 315 Posting Shark

You are stuck in and endless loop because you keep adding to "available" following the recursive call. What is the objective here?

public void recursion(List<int> history, List<int> available)
        {
            if (available.Count == 0)
            {
                for (int i = 0; i < history.Count; i++)
                {
                    Console.Write(history[i].ToString() + "->");
                }
                Console.WriteLine(" ");
                return;
            }
            for (int i = 0; i < available.Count; i++)
            {
                history.Add(available[i]);
                available.RemoveAt(i);
                recursion(history, available);

                available.Add(history[history.Count - 1]);
                history.RemoveAt(history.Count - 1);



            }
            return;
        }
DdoubleD 315 Posting Shark

Is this program throwing an exception? I did a walkthrough and noticed you are using b[i] , but you never assign/initialize values. Also, b[i] values never get changed/updated that I can tell, so the result is always the same.

for (int i = 0; i < 5; i++)
            {
                if (b[i] == false)
                {
                    available.Add(place[i]);
                }
            }
DdoubleD 315 Posting Shark

hi.. thanks... can you understand the problem?.. If you could, can you please explain it to me? Thanks. the thing is, our prof don't want to tell what we should really do. Ouch. :(

What is not clear from your original quote is what the actual requirements of the assignment are. It seams like you original problem statement has both ideas and the problem mixed in and rather than ask a bunch of questions to find out what it is exactly you need to do, you should state that, then you could ask questions about ideas you have and for specific suggestions, etc.:)

DdoubleD 315 Posting Shark

It's not clear by your description what you want us to do. You provided some code, and some sort of description of what it does, but not whether you want it to do something different, or you are getting an error, etc.

Please clarify how you want to be helped.

DdoubleD 315 Posting Shark

Welcome to C#! As far as I can tell so far, you need help understanding what your assignment is, and you are not ready to begin coding it in C# until you do understand that. I think you should contact professor or classmate to get a better understanding of the actual assignment first, begin coding what you can in C#, then begin asking C# questions if you need too.

ddanbe commented: Nice response! +8
serkan sendur commented: chic +7
DdoubleD 315 Posting Shark

Oh, I hope someone can help you with that. You need to implement some sort of callback from the database load provided your db library supports that, which I think it probably does, but I don't know. What tool are you using for DB?

DdoubleD 315 Posting Shark

Here are a couple of other things to check/try:
- if the EXE you are referencing is also in your solution, make sure it built without errors.
- if it built OK, try deleting the reference to it in the module that won't build, then add the reference again. I've seen this problem before.

DdoubleD 315 Posting Shark

Do you have all the needed references added to the your assembly inherited by the class? When you say the inherited class is not exposed, do you mean by definition, or that you just can't see it when trying to use it?

DdoubleD 315 Posting Shark

also note that one these accessible classes is a child of another unexposed class.

Are you saying that you are trying to access a class that is inside of another class that is not exposed? Because that sort of explains the problem. To expose the "child class definition", you could move that outside of the unexposed class.

If that's not the problem and I have misunderstood, try using the fully qualified name: namespace.class.member , build and submit the complete error text generated.

DdoubleD 315 Posting Shark

Something else to check: if trying to access a static method, it needs to be proceeded by the class name: TheClassName.MethodName()

DdoubleD 315 Posting Shark

I've exposed objects from an EXE before and not had this problem. Can you attach one of the smaller file objects that is not properly exposing itself to modules referencing the EXE?

Also, have you verified the object that is not getting exposed is using the namespace you are expecting?

DdoubleD 315 Posting Shark

Here is a link to fairly good article on creating a custom UserControl for a ProgressBar: http://support.microsoft.com/kb/323116

It's straightforward and I like the way the introduction gives a clear depiction of the usage as well as the step-by-step approach to creating it in VS.

DdoubleD 315 Posting Shark

I ran into that StringBuilder code using StreamWriter on a another website. It's not going to work simply appending it to another word document. To understand why, do the following:

Set a breakpoint after the export of your CrystalReport and run program to there.

Open doc in Notepad, and look over the contents: note the length of the document, spacing, formatting, reference to CrystalReports, etc,. It's all viewable text, so you should have no problem.

Close notepad.

Now, open it in Word and go to the end of the document by hitting PgDn a few times. Do a Ctrl-Enter, which will insert a manual page break. PgDn into the new page.

Now, type in some text like: "some text", and save the document.

Now, open again in Notepad and notice the changes Word made to that document--it's pretty drastic. Not only does it create a bunch of new formatting script, it rearranges the existing script too. Search for the string "some text" and look at how it was embedded inside formatting code.

You are mingling data inside of an interprative format that must be formatted or reformatted correctly so that Word understands what to do. The reason that simple StringBuilder output to a stream probably works with a new file is because when Word first reads it, it will try to determine the format at that time, which is just HTML. However, when you append the HTML to the existing Crystal embedded document, it is not expecting information outside …

DdoubleD 315 Posting Shark

As an after thought, have you considered just adding a field to the end of your report that you can set to text "hany", or whatever, so that when it is exported it will properly format it in the word document? Not sure exactly what you need to do for your project, but a text field in the report or page footer section seems like it might be the way to go.

DdoubleD 315 Posting Shark

i have a problem in writing in word document the proble is that i want to append a string after a table i made in that document but it overides it...

Ok, your text is being appended to the word document, as you have told it to do. The problem is how Word is interpreting the document. When debugging, I saw that the string "hank" was indeed getting in the document, so I played with some formatting changes in the code and used BinaryWriter instead of StreamWriter so I could position the stream 1 position away from the EOF:

//StreamWriter sWriter = new StreamWriter(fStream);
            BinaryWriter sWriter = new BinaryWriter(fStream);
            sWriter.Seek(1, SeekOrigin.End);
            sWriter.Write("hany}");

Now, Word will display the appended text on a new page. Notice the addition of the closing brace in the text: "hany}". That is because I overwrote the closing brace already existing in the file (with Seek) and I wanted word to see "hany" before the final closing brace.

What you are dealing with at this point is Word scripting and you need to figure out how you can modify word documents externally or use some library that facilitates doing so, instead of using standard stream writers.

If the word "hany" is all you need appear at the end of the doc, and you wanted it to appear on the same page, you might be able to modify the export options to not fill the entire page with the table, then simply use the quick …

DdoubleD 315 Posting Shark

thanks alot
that's my project and it's databases
my code is supposed to make crystal report ,save it as a word document then append some words in that word document
would you just press "save report" in form1.cs then "save " in form2.cs the append code in save menustripitem handler in form2.cs

thanks alot for ur help it's really appreciated

I've compiled the project and am looking at the warnings, particularly the missing reference: Microsoft.Office.Interop.Word

I am installing the class library download and will get back to you...

DdoubleD 315 Posting Shark

I am receiving this exception

(An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)


plz help

Did you check the SQL Server setup (via the link I gave you below) to ensure you have the proper connections enabled?

Do you have local and remote connections enabled for the server?
If you are not sure, check out this link: Setup (click mouse here to view link)

DdoubleD 315 Posting Shark

actually they did nothing i don,t know why but any way appreciated
sorry for replying lately

No problem. When you say "did nothing", I really don't know what that means.

I'm not sure if know, but you can append to any file you want. However, that doesn't mean that the reader (MS Word in this case) of the file will understand the data appended.

Anyway, if you will post your code so I can run it on my end, I will help you figure it out.

DdoubleD 315 Posting Shark

Thank you but how would I pass the vars of the Numericupdown(in form sp+ it needs to be the selected string in there) to label2 (in form1),and I want to show that selected string from numeric' in label 2 when button on sp is pressed, I can't find how to do it.

Because NumericUpDown.Value is type 'decimal', you need to convert to and from type 'string' to store and retrieve from labels, textboxes, etc.

numericUpDown1.Value = Convert.ToDecimal(myString);
//and convert a decimal to string:
            myString = Convert.ToString(numericUpDown1.Value);

So, you can decide how you want to pass the value between the forms because the conversion is quite easy.

Be sure to consider my recommendation for putting your shared vars in a class (e.g. class MyVars or something). Otherwise, you are eventually going to find the vars are not referencing the same data on both forms.

DdoubleD 315 Posting Shark

DdoubleD's post, i think is what you really needed.

But I think this is what you are looking for

//SP Form
   public string x;
   public string y;

    public class SP : Form
    {
        Form1 form = new Form1(x,y);
        form.Show();
    }

//Form1

   string x,y;
   public Form1(string x, string y)
  {
     this.x = x;
     this.y = y;
  }

correct me if I'm wrong

That will work as long as second form does not modify the variables because when the strings get assigned they will get assigned new strings and thus a different reference from the starting variables.
This is why I placed the variables inside class MyVars.

DdoubleD 315 Posting Shark

If both of these apps exist within the same solution, it's pretty easy to do. You can reference another exe the same as you do a dll and vice-versa.

DdoubleD 315 Posting Shark

Glad to have helped. Can you please mark as SOLVED. Thanks.

DdoubleD 315 Posting Shark

I was thinking of replacing the symbol in the script itself.
If textbox1.text not null then display in the label.
Same goes to textbox2.text but with the symbol. Now when textbox2.text is cleared then remove symbol. Right?

If that syntax is correct for the scripting language, then you are on the right track.

DdoubleD 315 Posting Shark

Brilliant! I was actually working like that. But now the problem is when the user deletes the text in the textbox the ',' should also go right?

How to remove that?

Well, now that's a good question. I haven't programmed in ASP.NET, VB or Java script. That function I wrote (UpdateLabel2) isn't exactly C# code, and it took me a while to figure that out. Do you know VB or Java script?

I think a good way to handle it would be to create another script function that accepts a string, then returns another string, with or without the comma (or other delimiter), depending on whether the passed in string is blank (empty). You could then substitute this new function call in place of each of the three textbox (and comma literal) references in the concatentation within the UpdateLabel2() function.

Make sense?

DdoubleD 315 Posting Shark

You can just modify the function to concatenate the values and call it to process keyup events for all three textboxes:

protected void Page_Load(object sender, EventArgs e)
        {
            String scriptText = "";
            scriptText += "function UpdateLabel2(){";
            scriptText += "   Label1.innerText = " +
                " document.forms[0].TextBox1.value + ',' + " + 
                " document.forms[0].TextBox2.value + ',' + " +
                " document.forms[0].TextBox3.value";
            scriptText += "}";
            this.ClientScript.RegisterClientScriptBlock(this.GetType(),
               "OnKeyUpScript", scriptText, true);
            TextBox1.Attributes.Add("onkeyup", "UpdateLabel2()");
            TextBox1.Attributes.Add("onblur", "UpdateLabel2()");
            TextBox2.Attributes.Add("onkeyup", "UpdateLabel2()");
            TextBox2.Attributes.Add("onblur", "UpdateLabel2()");
            TextBox3.Attributes.Add("onkeyup", "UpdateLabel2()");
            TextBox3.Attributes.Add("onblur", "UpdateLabel2()");
        }
DdoubleD 315 Posting Shark

Thankyou very much. It works like charm!
But this works with one text box. How can I do with 3 textboxes?

OK. You need to concatenate all three textboxes into the one label?

DdoubleD 315 Posting Shark

I thought I sent this a few minutes ago, but I guess not. Here is another way to do it in the asp form's page load and without the Java function:

protected void Page_Load(object sender, EventArgs e)
        {
            String scriptText = "";
            scriptText += "function UpdateLabel2(){";
            scriptText += "   Label1.innerText = " +
                " document.forms[0].TextBox1.value";
            scriptText += "}";
            this.ClientScript.RegisterClientScriptBlock(this.GetType(),
               "OnKeyUpScript", scriptText, true);
            TextBox1.Attributes.Add("onkeyup", "UpdateLabel2()");
            TextBox1.Attributes.Add("onblur", "UpdateLabel2()");
        }
DdoubleD 315 Posting Shark

OK, 1st how could I actually change the label?
2 Where to put that code you gave me?

To change a label's text:

label1.Text = "some new text";

or,

label1.Text = myVars.text1;

As far as where to put that other code, I thought it was self-explanatory, but I would need to see your actual code to be more specific. If you post your code, I'll try to help with that.

DdoubleD 315 Posting Shark

Note the attributes for the TextBox:
onblur: control losing focus
onkeyup: after each keystroke

The value "UpdateLabel();" tells it to run that script upon those events.

<head runat="server">
    <title></title>
</head>
<script type="text/javascript">
function UpdateLabel()
{
document.getElementById('Label1').innerText = document.getElementById('TextBox1').value;
}
</script>
<body>
    <form id="form1" runat="server">
    <div style="height: 83px">
			<br />
			<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
			<asp:TextBox ID="TextBox1" runat="server" onblur="UpdateLabel();" onkeyup="UpdateLabel();">
			  </asp:TextBox>
    </div>
    </form>
</body>
DdoubleD 315 Posting Shark

I know how to open a form but I asked how could I transfer from From2 that has a list box the selected item from the list box , and when button that transfers is pressed to show the value of the selected listbox item in the label in form1.

If you understand the MyVars code I gave you, try to make it work and show your code with questions or problems you have. It sounds like you want someone else to write the code for you, but we don't do that.

DdoubleD 315 Posting Shark

What do you mean call?
Could you give me an example code?(for my 1st question..)

There are soooo many ways to do this. Here is one technique:

public class MyVars
        {
            public string text1;
            public string text2;
        }

    public class Form1 : Form
    {
        MyVars myVars = new MyVars();

        SP sp = new SP (myVars);
    }

The above will pass a MyVars object to your SP form, which can be modified and the changes will be available to Form1.

DdoubleD 315 Posting Shark

In other words, inside of Form1's class, you create form "SP", such as:

SP sp = new SP();
sp.ShowDialog();
DdoubleD 315 Posting Shark

Does this label1.Text need to be updated after each key stroke in the TextBox, or can it be updated after user has finished editing?

DdoubleD 315 Posting Shark

There are several ways to do this. Does form1 call form SP?

DdoubleD 315 Posting Shark

Do you have local and remote connections enabled for the server?
If you are not sure, check out this link: Setup

DdoubleD 315 Posting Shark
myString.Replace("<Fresh Food>", "");
myString.Replace("</Fresh Food>", "");

Include newline if you want that removed too:

myString.Replace("<Fresh Food>\n", "");
DdoubleD 315 Posting Shark

I'm providing this attachment because I've been searching all morning for flash related api stuff and have not found what I was looking for, but I happened upon this c# API. It is an example project in VS. I hope it will save you some time. Regards.

DdoubleD 315 Posting Shark

Would that work because my understanding of it as im reading it is that it assigns a string a numerical value then compares it to another number. Would that not just tell you which word is greater in length?

No, it works on the sort order of the string: String.CompareTo

DdoubleD 315 Posting Shark

also

if (s.Equals("Hello"))
                bool b = true;