jatin24 21 Junior Poster in Training

So i have this SharePoint 2010 Publishing site collection and i can create subsites under it simply by going to Site Actions > Create New Sites.

There's a button that says 'More Options' which gives me more options for the new subsite.

I get extra options like 'Permissions' and 'Navigation Inheritance'. I would like to add an extra settings option here.. (programatically using event receivers maybe). And also add a corresponding settings page somewhere in the Site Settings.

So my question is, if this is possible at all? If yes... then how?

I would ideally like to configure the navigation breadcrumb here...

Thanks!

jatin24 21 Junior Poster in Training

Are you using the correct version of the Interop Assemblies?

jatin24 21 Junior Poster in Training

Im trying to customize the Contact Card that appears on the Office Communicator 2007. The default information about the pesron that appears on the Contact Card is not enough and would like to include some more information.

I've downloaded the API and also looked into adding custom tabs using an xml file, but that is not exactly what im looking for. Moreover i think that is available only in the R2 version.

Another alternative i tried was by using 'absconfig.exe' which comes with OC Resouce kit tools. For some reason the file throws an exception and doesnt run.

Not sure if this is the relevant forum for my problem...

Any help would be appreciated! Thanks!

jatin24 21 Junior Poster in Training

DELETE from [Staff]

However id recommend using stored procedures. Much faster, safer and efficient!

jatin24 21 Junior Poster in Training

Find out more about the gateway you are registered with. I've done something similar using the Clickatell Gateway. Any of the popular gateway would have a 'Developers' section on their website where you can find information about different types of technologies/ways you can use for using their gateway and create your custom application.
Download the API's. They would have examples as well, and try it out.

jatin24 21 Junior Poster in Training

I had to do something similar about a week ago and did something very similar what Diamonddrake suggested. However this method looses all the formatting of the text that was on the doc file.

Is there any way you can preserve that formatting when its copied to the RichTextBox? If you manually select a text, copy and paste, the text pasted on the RichTextBox usually retains the formatting...
I think it would be something to do with the GetData(DataFormats.???) but not sure.

jatin24 21 Junior Poster in Training

hey thanks for that. It does work.. had to make some minor modifications but it works.

But it still is annoying that i have to do this to protect the datagridview! It very strange how one fine day the dataGridView decides to clear all its columns! This surely seems to be an annoying bug that Microsoft has not taken care of or even mentioned it anywhere! At least i could'nt find it.

Anyway, thanks for ur help, and i can just pray that the other controls dont have mood swings like dataGridView!!

jatin24 21 Junior Poster in Training

No, the data is not really binded to a data source.

The columns were manually created, and the data is fetched from a database, its formatted accordingly and inserted in corresponding locations.

You mean i can simply copy and paste the code from the designer.cs to the .cs file? Should that be done inside the Form_load or before InitializeComponent()?

jatin24 21 Junior Poster in Training

I'm facing this strange problem while working with DataGridView. In my application that i'm building, there is a form with some tabs, and im using the dataGridView Controls in some of the tabs.

These dataGridView controls have already been configured, with a number of columns already added, and has been working perfectly fine for a long time.

Today when i open the project, i see that one of the dataGridView has all the columns mysteriously deleted! I had to re create the entire control all over again. As soon as i finish that, i see that its happened to another datagridview in the same form!!
I cannot add the same columns again as it says that the name is already in use by another component. So basically i will have to delete the dataGridView and recreate it again if i want the same column names!

Has anyone else come across this weird problem? I've only found one reference to something like this on google here:
http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/46d8c2b8-3cd7-449a-8cbf-424b67002111

but the solution wasent really helpful. any hints/help would be appreciated!

jatin24 21 Junior Poster in Training

You cannot edit this application coz the files you have are the binary files and not the source code.
You need to get the Source Code first. If you think the source code is in VB or C#, you need to install Visual Studio, Visual Studio Express. I think you can download a free version from the Microsoft website.

jatin24 21 Junior Poster in Training

Basically you will have to create a DataTable, and work on that. The datatable would have the same columns as your grid view. you can add new rows, and data accordingly to this DataTable, and finally you will have to set the datasource for the gridView as this datatable you have created.

Have a read through this article:

http://www.victorchen.info/add-rows-to-a-datatable-in-c/

jatin24 21 Junior Poster in Training

Did you mean DataGridView in C# windows based applications or GridView in ASP.NET ?

jatin24 21 Junior Poster in Training

Try typing the IntegratedSecurity line after you have specified the ReportSource.

jatin24 21 Junior Poster in Training

Hey thanks for that! It works!!

jatin24 21 Junior Poster in Training

Try this:

crystalReportViewer1.LogOnInfo[0].ConnectionInfo.IntegratedSecurity = true;

Insert this line after you've set the ReportSource property.

jatin24 21 Junior Poster in Training

Are you sure that the Username in Login1.Username is a string? convert it to string just to be safe.

jatin24 21 Junior Poster in Training

Start with looking at Socket Programming.

http://www.devarticles.com/c/a/C-Sharp/Network-Programming-in-C-sharp/

http://www.csharphelp.com/archives/archive127.html

Try out some examples. The 2nd link has some code example.
See how you go, if you're stuck then post questions here.

jatin24 21 Junior Poster in Training

Hi,

Im trying to transfer some text from the richTextBox into an existing MS word template at a specific location.
I am able to transfer text to any location i like, but i want to retain the formatting of the text from the richTextBox.

Im trying to copy the text to the clipboard, and pasting it in Word, but its not working for some reason.

Microsoft.Office.Interop.Word.Selection sel = oWord.Selection;
Clipboard.Clear();                    
//richTextBox4.SelectAll();
Clipboard.SetDataObject(richTextBox4.Rtf, true);                        
                    
IDataObject data = Clipboard.GetDataObject();                    
sel.InsertBefore(data.GetData(DataFormats.Rtf).ToString());

Can anyone tell me how to fix this, or is there any other way to transfer a chunk of text from richTextBox to MS Word without loosing the formatting.
please note: i know i can directly save data from richTextBox to an rtf or doc file.. i want to insert the data in an existing template.

thanks!

jatin24 21 Junior Poster in Training

Regarding Mail merge and bookmarks, are you not allowed to use it or you are not sure how to use it?
Coz it will make things quite easy and manageable. The only other way i can think of is by reading the contents of the word file, and simply performing a string replace on "Name_of _applicant". and then writing it back to the file.

The disadvantage is that you will loose all the formatting for the text.

I am currently working on word integration with C# as well...

jatin24 21 Junior Poster in Training

What about Mail Merge field.. can you use that?

jatin24 21 Junior Poster in Training

Just use the following in your combo box selected index changed event handler

string font = comboBox1.SelectedItem.ToString();
            label3.Font = new System.Drawing.Font(font, 14);

I just tried that and it works.

jatin24 21 Junior Poster in Training

Instead of comboBox1.SelectedIndex, try using comboBox1.SelectedItem

jatin24 21 Junior Poster in Training

Try this:

SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.Text;
            cmd.Connection = cn; // This is your connection string
            cmd.CommandText = "SELECT * from zip_table where zip = " + textZip.Text;

            cn.Open();
            
            SqlDataReader dr = cmd.ExecuteReader();
            dr.Read()
            textCity.Text = dr["City"].ToString();
            textState.Text = dr["State"].ToString();
            cn.Close();

Im assuming you have your connection string sorted out (cn).
I would personally use stored procedures instead of a direct query, but this one will work just as well.

jatin24 21 Junior Poster in Training

I've done something like that in an application i built sometime ago.

firstly, you dont need two seperate tables. Just have one table with the zip code, city, state etc and everything you need.

You can create a button next to the text box and on the click event, just write the code for connecting to the database and running a simple query like
SELECT * from zip_table where zip = <<zip code from textbox>>
Get the result and display in the relevant text boxes..

jatin24 21 Junior Poster in Training

You can probably use something like an ArrayList and keep storing each and every path traversed there. So if you wanna go back, the last path stored will be the last visited and so on.

To check if you are at the root, you can check the number of "\" in the path string....

jatin24 21 Junior Poster in Training

Use:

description = description.Substring(0, 14);

or..

under the console.WriteLine(), display description.SubString(0,14) instead of just description. :)

jatin24 21 Junior Poster in Training

I'll post my code after my questions.

1. Near the very end, I have DisplayIntroMessage() called for the event that the user desires another order. Is this all that I need to do to restart the process?

Yes that should restart the process.

2. If that is all that is needed, what is the easiest way to save the total from each prior order(s) to add to newer ones.

Are you trying to save individual orders? in that case you can make a global ArrayList and store whatever you want in there.
If you wish to permanently store the totals, you might have to use file IO.


3. In the DoTheMath() method, I am asking the user whether or not they desire another order? I'm not getting this to work out just right. I don't know what to do with it. I've tried several things only to end up unsuccessful in all of them.

your if statement is wrong.

if (anotherOrder != "yes" || anotherOrder != "no")
This will always return true no matter what you enter.
Also, you are using Convert.ToChar(), and comparing a string.
simply use the ReadLine() function to read the input. This will be in string.
change it something like this:

int flag = 0;

do
anotherOrder = Console.ReadLine();

if (anotherOrder == "yes" || anotherOrder == "Yes" || anotherOrder == "YES")
{
DisplayIntroMessage();
flag = 1;
}
else if (anotherOrder == "no" || anotherOrder == …
jatin24 21 Junior Poster in Training

Put the code for Converting to datetime and validating in the 'Leave' event handler for the textbox.

jatin24 21 Junior Poster in Training

In that case you will have to parse the input using the following:

DateTime input = DateTime.Parse(textBox.text);
// you can now use the variable input to check..

You will have to make sure that the input is in correct format. Put this in a try catch to avoid application to crash.

jatin24 21 Junior Poster in Training

Well..yeah.. wasent sure if he ment 5 years ahead of today or 5 years before today! I assumed its checking the date to be withing 5 years ahead of today.

jatin24 21 Junior Poster in Training

I tried the exact same thing, it seems to be working!

jatin24 21 Junior Poster in Training

You will need to use a ConnectionString and SqlCommand.

Create a new connection string in the project properties, under Settings. Give it a name, type = string and Value something like this:

server=YourServerName;database=DatabaseName; Integrated Security=SSPI;

or

server=YourServerName;database=DatabaseName; Username=username; Password=password;

Once you have the connection string, include it in the class by using the following:

static SqlConnection cn = new SqlConnection(MyProject.Properties.Settings.Default.ConnectionString);

Now you can use this connection string as many times as you want.
In the button click event you can do something like this:

SqlCommand cmd = new SqlCommand("Your command text (stored procedure or SQL Query goes here", cn);
cmd.CommandType = CommandType.StoredProcedure; // if its a stored procedure or
cmd.CommandType = CommandType.Text; // if its a simple query.

cn.Open();
cn.ExecuteNonQuery();
cn.Close();

You can do much more, you can pass parameters to stored procedures if you are using them, return values etc.
Search on google, you will find lots of resources. This will get u started.

ddanbe commented: Good explanation. +13
jatin24 21 Junior Poster in Training

simply use the 'Value Changed' event of the DateTimePicker control.

if (dateTimePicker1.Value > DateTime.Now.AddYears(5))
        MessageBox.Show("Date should be within the next 5 years");
jatin24 21 Junior Poster in Training

Try this:

Microsoft.Office.Interop.Excel.Application exc = new Microsoft.Office.Interop.Excel.Application();
            exc.Visible = true;
            _Workbook workbook;
            _Worksheet worksheet;
            
            Workbooks workbooks = exc.Workbooks;
            workbook = workbooks.Add(true);
            Sheets sheets = workbook.Worksheets;
            worksheet = (_Worksheet)sheets.get_Item(1);

            // start inserting your values here.
            Range range1 = worksheet.get_Range("A1", "A1");
            string[] array1 = new string[1];
            array1[0] = "Some text";
            Object[] args1 = new Object[1];
            args1[0] = array1;
            range1.GetType().InvokeMember("Value", System.Reflection.BindingFlags.SetProperty, null, range1, args1);

            // You can modify this above section of code accordingly and put it in a for/foreach loop to insert values at different locations.

Make sure to include the Microsoft Excel 12 Libraries before you do this.

jatin24 21 Junior Poster in Training

Use the 'Leave' Event Handler for the second textbox.
Write in the code for whatever you want to display, in this event handler.

jatin24 21 Junior Poster in Training

Well if you are opening form2 from form1, then it can be done quite easily.
Simply create a public class level variable in form2:

public string myStr;

In form1, use this to open up form2:

form1 f = new form1();
f.myStr = textbox1.text;
f.show();

could'nt really understand the 2nd half of your message. x and y are classes or functions? what exactly are you trying to do there?

jatin24 21 Junior Poster in Training

Not sure how you could do that using the browsers you have installed (firefox/IE) but an alternative could be to use the 'WebBrowser' control in C#. Just make a form, and drag the WebBrowser control. Set the Dock property to Fill, and u can change the URL of this control as many times as you want whenever you want.
You can give it a go, although im not sure if its gonna be the perfect solution.

jatin24 21 Junior Poster in Training

Well in any database driven application, i think any changes to the database will cause a lot of trouble in the working of the application. Esp if you are playing around with columns of tables.
While adding/removing columns, you will have to make appropriate changes in the queries/stored procedures as well, else you will get lots of errors.

If you want to remove a column, i dont think theres anyway to do that without loosing the data. Unless you retrieve all the values of that column in your application somewhere, and then store it elsewhere (a file or maybe in the database itself).

jatin24 21 Junior Poster in Training

Well you can put the code i gave you in a function, and call that function in each textBox TextChanged Event.

You can use textBox Leave Event as well if you like, if you dont want the function to be called after each key stroke.

jatin24 21 Junior Poster in Training

Did'nt quite understand your question...

jatin24 21 Junior Poster in Training

Just use the following statement:

BTNAPPLY.Enabled = true;

inside the TextChange Event handler of the text box and the SelectedIndexChanged event of the combo box.

for the TextChange Event handler:

if (textBox.Text == "your required text")
      BTNAPPLY.Enabled = true;

for the SelectedIndexChanged Event Handler

if (cmbBox.SelectedItem == "your required seleciton")
        BTNAPPLY.Enabled = true;

Assuming that the button is disabled when the application starts.

jatin24 21 Junior Poster in Training

try this:

int n = listBox1.SelectedItems.Count;
            string[] array = new string[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = listBox1.SelectedValue.ToString();
            }
jatin24 21 Junior Poster in Training

have a read through this article:

http://msdn.microsoft.com/en-us/library/dfty2w4e(VS.80).aspx

jatin24 21 Junior Poster in Training

No worries mate! we're all here to help each other out ;) !!!

Regarding your question, i think i missed out mentioning one thing!! my bad!!
Ok when you right click and select properties, you will see different kinds of settings on the left. Application, Build, Build Events etc... goto 'Settings'. Simply add that connection string in the first row and save it.

ddanbe commented: Nice said:) +5
jatin24 21 Junior Poster in Training

You need to look at 'Setup and Deployment'

You will need to create a new project. Under 'Other Project Types' you will need to select 'Setup and Deployment'.

Depending upon your requirements you can choose the type of 'Setup and deployment' you would like to use. I guess 'Setup Project' would be the best.

You need to add this solution to your project that you want to create setup for.

You can read more about it here..

http://www.c-sharpcorner.com/UploadFile/vishnuprasad2005/SetupProjects12022005022406AM/SetupProjects.aspx

terdie commented: thanks man! +1
jatin24 21 Junior Poster in Training

The 'server explorer' and the 'SQL management tools' are just some tools that can be used to connect to the database server, and you can browse the database (tables, stored procedures etc).

I prefer stored procedures, they are much better, faster and safer. you can pass parameters to a stored procedure, you can basically use it like a function. You can do much more if you use it.. You can read more about it here

http://databases.about.com/od/sqlserver/a/storedprocedure.htm

To connect to database, you will need to use something like a Connection String.
You need to setup the database on one machine. To access this database you will have to use connection string, where you supply the name of the server, the database name, the username and password to connect and then you perform the functions you want on that machine.

Once you've done that, doesnt matter which machine you install the application to, as long as that machine is in the network and can access the machine with the database, you will be fine.


Right click on your projet on Visual Studio, goto Properties.
Add a new row, Name= 'ConnectionString' or whatever you wanna call it. Type = 'string', Scope = 'Application' and Value will be something like this:
'server=DATABASE-SERVER;database=Db_Name;Username=username;Password=password'
You can now use this connection string anywhere in your application. A sample code for accessing the database and the connection string:

SqlConnection cn = new SqlConnection(MyProject.Properties.Settings.Default.ConnectionString);
SqlCommand …
DdoubleD commented: good detail; friendly and helpful +2
jatin24 21 Junior Poster in Training

It looks like a web service, its asking for an API Key when trying to access that link. Not sure though.

Use try...catch, you might be able to find out which exact character is invalid which may lead to a clue.

jatin24 21 Junior Poster in Training

Hi,

Well the database is updated instantly as soon as something is added/modified. I dont think there is any need to refresh it from the application end. However if you are using the 'Server Explorer' from Visual Studio, or SQL Management Tools, then u will need to refresh manually to view the updated data.

What you will need to do is, as soon as something is added, you will need to reload the data again to view the updated values. Lets say you are using dataGridView. You will need to clear and load the data again so that you can see the updated values. Why dont you post your code here so it will give a better idea of what exactly you are doing and where the problem may be.

Manipulating data in the database can be done by using different ways. One of the most secure ways i would say is by using Stored Procedures. Using SqlCommand is also fine but not as safe as Stored Procedures.

Did'nt quite understand Q4. Arnt you connecting to the database already in your application? you mentioned you are using SqlConnection, SqlCommand etc..

jatin24 21 Junior Poster in Training

Well i've figured out how to create tables.. It goes something like this if anyone is facing the same problem:

Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.ApplicationClass();
            app.Visible = false;

            object start = 0;
            object end = 0;
            object oNull = System.Reflection.Missing.Value;

            Document doc = new DocumentClass();
            doc = app.Documents.Add(ref oNull, ref oNull, ref oNull, ref oNull);

            Microsoft.Office.Interop.Word.Table tbl = doc.Tables.Add(doc.Range(ref start, ref end), 10, 2, ref oNull, ref oNull);
            Random rnd = new Random();
            
            for (int i = 0; i < 10; i++)
            {                
                tbl.Rows[i + 1].Cells[1].Range.Text = "Run# :" + ((int)i + 1).ToString();
                tbl.Rows[i + 1].Cells[2].Range.Text = "Value :" + rnd.Next(0, 2000).ToString();
            }

However my next problem is formatting the cells for this table that's just created. Until now i am only able to find how to set the width and height of cells/rows/columns for the table. I need to find out how to change the backcolor/forecolor, font style etc for a particular cell or the entire row.

Any help will be appreciated!

jatin24 21 Junior Poster in Training

Try the following:

Application objOutlook = new ApplicationClass();
            NameSpace objNS = objOutlook.GetNamespace("MAPI");

            MailItem objmail = (MailItem)objOutlook.CreateItem(OlItemType.olMailItem);
            objmail.To = "sample.email@domain.com;
            objmail.BCC = "bcc@domain.com";
            objmail.CC = "cc@domain.com";
            objmail.Subject = "Subject of the email goes here";
            objmail.Body = "Body of the email goes here...";

You dont have to use all the above mentioned attributes (To, BCC, CC, body etc) if you dont want to.
You would also have to include the Microsoft Office Libraries. Right click on the project on visual studio, select 'Add Reference'
Select 'COM' tab
Scroll down to 'Microsoft Office 12 Object Library and add it.
Add Microsoft Outlook Object Library as well.

and make sure you include the following as well:

using Microsoft.Office.Interop.Outlook;

before using the above mentioned code.