Click here to Skip to main content
12,356,455 members (68,983 online)
   

C#

 
QuestionFTPS SSL/TLS Issue on Some Computers Pin
SimpleData11-Sep-09 2:28
memberSimpleData11-Sep-09 2:28 
QuestionC# Background Worker losing variable value in Progress Pin
Wheels01211-Sep-09 2:15
memberWheels01211-Sep-09 2:15 
AnswerRe: C# Background Worker losing variable value in Progress Pin
DaveyM6911-Sep-09 2:56
mvpDaveyM6911-Sep-09 2:56 
GeneralRe: C# Background Worker losing variable value in Progress Pin
Wheels01211-Sep-09 3:48
memberWheels01211-Sep-09 3:48 
GeneralRe: C# Background Worker losing variable value in Progress Pin
DaveyM6911-Sep-09 4:14
mvpDaveyM6911-Sep-09 4:14 
AnswerRe: C# Background Worker losing variable value in Progress Pin
Alan N11-Sep-09 2:56
memberAlan N11-Sep-09 2:56 
AnswerRe: C# Background Worker losing variable value in Progress Pin
DaveyM6911-Sep-09 3:10
mvpDaveyM6911-Sep-09 3:10 
QuestionDBNull error Pin
kanchoette11-Sep-09 1:38
memberkanchoette11-Sep-09 1:38 
AnswerRe: DBNull error Pin
monstale11-Sep-09 2:22
membermonstale11-Sep-09 2:22 
AnswerRe: DBNull error Pin
J4amieC11-Sep-09 2:22
mvpJ4amieC11-Sep-09 2:22 
AnswerRe: DBNull error Pin
PIEBALDconsult11-Sep-09 4:28
memberPIEBALDconsult11-Sep-09 4:28 
QuestionHow do I read in a h246 .mp4 file and change some hex in the file and then save the file back out? Pin
thestonefox11-Sep-09 1:05
memberthestonefox11-Sep-09 1:05 
AnswerRe: How do I read in a h246 .mp4 file and change some hex in the file and then save the file back out? Pin
stancrm11-Sep-09 1:22
memberstancrm11-Sep-09 1:22 
QuestionC# Excel. Find a specific cell and write in string data into the cell to the right of the found cell. [modified] Pin
gjx_junxian198911-Sep-09 0:16
membergjx_junxian198911-Sep-09 0:16 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Excel;
using System.Windows.Forms;
using System.Reflection;


namespace testtesttestExcel
{
public partial class Form1 : Form
{
public Form1()

{
InitializeComponent();
}


//Declare these two variables globally so you can access them from both
//Button1 and Button2.
Microsoft.Office.Interop.Excel.Application objApp;
Microsoft.Office.Interop.Excel._Workbook objBook;

Microsoft.Office.Interop.Excel.Workbooks objBooks;
Microsoft.Office.Interop.Excel.Sheets objSheets;
Microsoft.Office.Interop.Excel._Worksheet objSheet;
Microsoft.Office.Interop.Excel.Range range;


private void button1_Click(object sender, System.EventArgs e)
{

try
{
// Instantiate Excel and start a new workbook.
objApp = new Microsoft.Office.Interop.Excel.Application();
objBooks = objApp.Workbooks;
objBook = objBooks.Add(Missing.Value);
objSheets = objBook.Worksheets;
objSheet = (Microsoft.Office.Interop.Excel._Worksheet)objSheets.get_Item(1);

//Get the range where the starting cell has the address
//m_sStartingCell and its dimensions are m_iNumRows x m_iNumCols.
range = objSheet.get_Range("A1", Missing.Value);
range = range.get_Resize(5, 5);

//Create an array.
double[,] saRet = new double[5, 5];

//Fill the array.
for (long iRow = 0; iRow < 5; iRow++)
{
for (long iCol = 0; iCol < 5; iCol++)
{
//Put a counter in the cell.
saRet[iRow, iCol] = iRow * iCol * iCol;
}
}

//Set the range value to the array.
range.set_Value(Missing.Value, saRet);
objApp.Visible = true;
objApp.UserControl = true;

}

catch( Exception theException )
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat( errorMessage, theException.Message );
errorMessage = String.Concat( errorMessage, " Line: " );
errorMessage = String.Concat( errorMessage, theException.Source );

MessageBox.Show( errorMessage, "Error" );
}



Microsoft.Office.Interop.Excel.Range currentFind = null;
Microsoft.Office.Interop.Excel.Range firstFind = null;

string A = "16";

// You should specify all these parameters every time you call this method,
// since they can be overridden in the user interface.
currentFind = objSheet.Cells.Find(A, Type.Missing,
Microsoft.Office.Interop.Excel.XlFindLookIn.xlValues, Microsoft.Office.Interop.Excel.XlLookAt.xlWhole,
Microsoft.Office.Interop.Excel.XlSearchOrder.xlByRows, Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, false,
Type.Missing, Type.Missing);

while (currentFind != null)
{
// Keep track of the first range you find.
if (firstFind == null)
{
firstFind = currentFind;

//textBox1.Text = currentFind.get_Address(true, true, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, false, Missing.Value);


}

// If you didn't move to a new range, you are done.
else if (currentFind.get_Address(Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing)
== firstFind.get_Address(Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing))
{
break;
}

currentFind.Font.Color = System.Drawing.ColorTranslator.ToOl
(System.Drawing.Color.Red);
currentFind.Font.Bold = true;


currentFind = objSheet.Cells.FindNext(currentFind);
}

}
}



After finding the cell containing "16", i want to write in string data to the right of it. how should i go about doin this. I did some research on the codes, but i kept getting errors. Please advise me on my problem. Thanks alot!!

modified on Friday, September 11, 2009 11:12 AM

QuestionWMI Pin
moein.serpico10-Sep-09 23:57
membermoein.serpico10-Sep-09 23:57 
AnswerRe: WMI Pin
d@nish 11-Sep-09 0:19
member d@nish 11-Sep-09 0:19 
AnswerRe: WMI Pin
moein.serpico11-Sep-09 0:29
membermoein.serpico11-Sep-09 0:29 
GeneralRe: WMI Pin
Henry Minute11-Sep-09 0:34
memberHenry Minute11-Sep-09 0:34 
AnswerRe: WMI Pin
moein.serpico11-Sep-09 0:38
membermoein.serpico11-Sep-09 0:38 
GeneralRe: WMI Pin
Henry Minute11-Sep-09 0:47
memberHenry Minute11-Sep-09 0:47 
GeneralRe: WMI Pin
moein.serpico11-Sep-09 1:52
membermoein.serpico11-Sep-09 1:52 
GeneralRe: WMI Pin
stancrm11-Sep-09 0:36
memberstancrm11-Sep-09 0:36 
GeneralRe: WMI Pin
Dave Kreskowiak11-Sep-09 4:19
mvpDave Kreskowiak11-Sep-09 4:19 
Questionproblems about how to cancel auto play from an application Pin
smilefishcc10-Sep-09 23:45
membersmilefishcc10-Sep-09 23:45 
AnswerRe: problems about how to cancel auto play from an application Pin
stancrm10-Sep-09 23:48
memberstancrm10-Sep-09 23:48 
QuestionRe: problems about how to cancel auto play from an application [modified] Pin
smilefishcc11-Sep-09 0:17
membersmilefishcc11-Sep-09 0:17 
QuestionNetwork speed limitation Pin
DeOiD10-Sep-09 23:43
memberDeOiD10-Sep-09 23:43 
QuestionCasting byte arrays to structures in C# [modified] Pin
Mikael Sundfors10-Sep-09 23:29
memberMikael Sundfors10-Sep-09 23:29 
AnswerRe: Casting byte arrays to structures in C# Pin
Luc Pattyn10-Sep-09 23:38
mvpLuc Pattyn10-Sep-09 23:38 
AnswerRe: Casting byte arrays to structures in C# Pin
PIEBALDconsult11-Sep-09 4:30
memberPIEBALDconsult11-Sep-09 4:30 
QuestionCrystal report subreport error... Pin
The_Collector10-Sep-09 23:21
memberThe_Collector10-Sep-09 23:21 
AnswerRe: Crystal report subreport error... Pin
matiIsGreat13-Sep-09 0:48
membermatiIsGreat13-Sep-09 0:48 
GeneralRe: Crystal report subreport error... Pin
The_Collector13-Sep-09 16:46
memberThe_Collector13-Sep-09 16:46 
Questionproblem in deployment Pin
gtag10-Sep-09 22:10
membergtag10-Sep-09 22:10 
AnswerRe: problem in deployment Pin
minnie mouse11-Sep-09 16:59
memberminnie mouse11-Sep-09 16:59 
QuestionHow to connect to a website and retrieve the page in C#? Pin
sheateng10-Sep-09 22:00
membersheateng10-Sep-09 22:00 
AnswerRe: How to connect to a website and retrieve the page in C#? Pin
Md. Marufuzzaman10-Sep-09 22:17
groupMd. Marufuzzaman10-Sep-09 22:17 
AnswerRe: How to connect to a website and retrieve the page in C#? Pin
vivasaayi11-Sep-09 0:53
membervivasaayi11-Sep-09 0:53 
GeneralRe: How to connect to a website and retrieve the page in C#? Pin
sheateng27-Sep-09 21:43
membersheateng27-Sep-09 21:43 
GeneralRe: How to connect to a website and retrieve the page in C#? Pin
vivasaayi28-Sep-09 3:52
membervivasaayi28-Sep-09 3:52 
AnswerRe: How to connect to a website and retrieve the page in C#? [modified] Pin
april_12345621-Sep-09 17:09
memberapril_12345621-Sep-09 17:09 
QuestionExcel interop issue Pin
manustone10-Sep-09 21:33
membermanustone10-Sep-09 21:33 
QuestionCurrent directory problem in MDI container form Pin
mutpan10-Sep-09 20:58
membermutpan10-Sep-09 20:58 
AnswerRe: Current directory problem in MDI container form Pin
Christian Graus10-Sep-09 21:03
mvpChristian Graus10-Sep-09 21:03 
GeneralRe: Current directory problem in MDI container form Pin
Leapsword11-Sep-09 1:55
memberLeapsword11-Sep-09 1:55 
AnswerRe: Current directory problem in MDI container form [modified] Pin
april_12345621-Sep-09 17:06
memberapril_12345621-Sep-09 17:06 
Questionaccess font colour paterns in ToolStripCombo box Along with name Pin
santosh_anu10-Sep-09 20:52
membersantosh_anu10-Sep-09 20:52 
AnswerRe: access font colour paterns in ToolStripCombo box Along with name Pin
Henry Minute11-Sep-09 0:05
memberHenry Minute11-Sep-09 0:05 
GeneralRe: access font colour paterns in ToolStripCombo box Along with name Pin
santosh_anu11-Sep-09 7:09
membersantosh_anu11-Sep-09 7:09 
GeneralRe: access font colour paterns in ToolStripCombo box Along with name Pin
Henry Minute11-Sep-09 9:09
memberHenry Minute11-Sep-09 9:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.160621.1 | Last Updated 29 Jun 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid