|
Can you write some sample code to attach an object of Microsoft.Office.Interop.Excel.Application to an already existing excel.exe application?
|
|
|
|
|
Hi everyone,
I am working in button click event and i want to get row index of selected row.
Kindly let me kknow.
Thank you in advance
(Riaz)
|
|
|
|
|
|
YourDataGrid.SelectedRows[0].Index
First check if YourDataGrid.SelectedRows.Count > 0
|
|
|
|
|
This is how to get selected row from DataGridView in .NET 2.0
Make sure there’s a single cell that is currently selected
Get current row index using {datagridview instance}.CurrentCell.RowIdex
Get the selected row using {datagridview instance}.Rows({current row index}).Cells({zero based index}).Value
Here’s the sample code :
Dim crow = DataGridView1.CurrentCell.RowIndex
dim txt as string
Try
txt = DataGridView1.Rows(crow).Cells(0).Value & ” || ”
txt = txt & DataGridView1.Rows(crow).Cells(1).Value & ” || ”
txt = txt & DataGridView1.Rows(crow).Cells(2).Value
MessageBox.show (txt)
Catch ex As Exception
‘ do nothing
End Try
WaelA
Senior Software Engineer
http://www.linkedin.com/in/waelalwirr
abu_wer@hotmail.com
|
|
|
|
|
Hi,
I want to change some looking of some control.
For example - i want to change some Button to be circle.
How can i do it ?
Thanks.
|
|
|
|
|
You can handle the paint event and do your own drawing. This[^] was my first hit when I searched.
|
|
|
|
|
Alternatively, you can do something like I did in this[^] reply if you don't want to handle the drawing of the entire control, this was for a pictureBox but works for other controls too.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Dear All,
I have a network program which has client and server.
The server will be listening the client at a specific port and IP address.
The client is connecting and writing the data to the server.
When the client connection is established the server will continuously listen the client and gets the packet sent by it.
When the time goes on the server takes up lots of memory in RAM and the CPU utilization goes to 80 to 100%.
The connection used was TCP.
Can any one tell me why this happens.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
M. J. Jaya Chitra wrote: CPU utilization goes to 80 to 100%
Probably because of incorrect usage of threads. Try to use asynchronous fashion methods (BeginXXX,EndXX) which is very efficient. Hard to tell more without seeing the code.
|
|
|
|
|
M. J. Jaya Chitra wrote: CPU utilization goes to 80 to 100%
looks like you are using while loop, instead of thread.
|
|
|
|
|
I am working on an assignment tt reads in *.cs files fr a given directory and do some evaluation with it. At first i thought it was just a small assignment, so Visual Studio is not required, then when i read my assignment requirement again, I find out tt I might require the use of Visual Studio (as our lec wants us to learn it for our upcoming big assignment).
And my code works under command prompt (can read all the *.cs files) but gives me a FileNotFound Exception when working under Visual Studio environment. Does anyone has any idea on how to solve this problem?
--------------------
C:\Documents and Settings\myname\My Documents\Visual Studio 2005\Projects\Stat
Generator\StatGenerator>StatGenerator.exe
Enter the directory name with the C# files to be evaluated:
C:\Documents and Settings\myname\My Documents\cs
Total of 3 C# files found.
File Name: StatGenerator.cs
author's_unix_id: myname
LOC without comments: 71
LOC with comments: 71
Comments lines: 0
File Not Found: Could not find file 'C:\Documents and Settings\myname\My Docum
ents\Visual Studio 2005\Projects\StatGenerator\StatGenerator\test.cs'.
Enter the directory name with the C# files to be evaluated:
|
|
|
|
|
Not sure I understand you - but when you build the project in VS it places the executable in a specific location (bin\debug by default) so that would be the folder from which any relative paths are generated - i.e. if your program tries to open a file called 'test.cs' without specifying a complete path, then it will just look in the same folder that the exe is in.
So - you could move your files to this folder, copy the exe from this folder to the folder containing the files, or specify the path to the folder containing the files in the program and be explicit when you open them.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
|
You see, this is what we don't want here. That screaming Subject annoys us
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za
|
|
|
|
|
OK - as per your title.
There's the door. Don't let it hit you on the way out.
|
|
|
|
|
Hi,
I am busy with an NTier Windows Application that has the following:
Presentation Tier (Windows Application)
In the presentation Tier I have a form with a Combobox.
DataAccess Tier (Class library)
This tier contains the DataSet TableAdapters.
DataEntityTier (Class library)
This tier contains the DataSet Validation and Structure.
DataService (WCF)
This tier connects to the DataAccess tier in order to retrieve the data.
I have successfully implemented the GetData() method via the WCF service. How can I implement the Fill() method? I currently have a combobox that I have set the datasource, datamember and valuemember but nothing gets populated. How can I get the data from the dataset to the combobox using WCF??
IService1 File:
[OperationContract]
WBGTS.DataEntities.dsEntities.IndustryDataTable GetIndustries()
Service1 File:
public WBGTS.DataEntities.dsEntities.IndustryDataTable GetIndustries()
{
WBGTS.DataAccess.dsIndustryTableAdapter taIndustry = new WBGTS.DataAccess.dsIndustryTableAdapter();
return taIndustry.GetIndustries();
}
Windows Form:
Form_Load(object sender, eventargs e)
{
ServiceReference1.ServiceClient proxy = new ServiceReference1.ServiceClient();
dsEntities.Industries.Merge(proxy.GetIndustries());
}
Illegal Operation
|
|
|
|
|
can you tell me little bit more in which layer your method fill ...
have your values in datareader ,create some business object that can hold these values.
return it to the presentation layer ... and read the values again
using the interface method ".GetDataTable(your method )"
i think via this way u can populate the value...
vikas da
|
|
|
|
|
Hi All,
does anyone come across this problem "the selected file is a visual studio solution file, but was created by a newer version of visual studio and can not be opened." i was trying to open a asp.net application created by visual studio 2003.net about 2 years ago, and now i cant open it in visual studio 2003.net? what the hell?
I have both visual studio 2005 and visual studio 2003.net installed on my machine. is this could be the .net 2.0 framework issue?
plz help
|
|
|
|
|
AndieDu wrote: is this could be the .net 2.0 framework issue?
Visual Studio solution files have nothing to do with the .NET framework.
AndieDu wrote: I have both visual studio 2005 and visual studio 2003.net installed on my machine
Could you have inadvertently opened the solution in Visual Studio 2005 and upgraded the project?
If you look at the solution file in Windows Explorer does it have a version number in the icon? If it is a Visual Studio 2005 file it will have an 8 in the bottom corner, otherwise a 7.1
|
|
|
|
|
excellent mate, thanks a lot, i can see teh solution icon has 8 on it.
now the issue is that i neither can open in 2005 nor in 2003.net and i do need to open it in 2003.net due to compability issue. can you guide me through?
many thanks
|
|
|
|
|
You could try
Here[^]
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
I fix it myself, if anyone come across the same issue just shoot me an emial n i ll guide you through to get around of it.
many thanks..
|
|
|
|
|
Hello fellow developers,
For simplicity sake, I know you are all busy, I'll get to the meat of the question:
What would be the fastest way to search a .DLL, .EXE and .config for a String value?
Here is the background info:
I have completed an application that searches "Locations" for configuration settings. It works very well, my only complaint is the File Searching functionality appears to be quite slow. Normally for a localized search I use the WinGrep application www.wingrep.com, which works very well and amazingly fast ( its written in C, so it should be ). I basically want the same functionality that WinGrep provides but add a nice manager feel to it, hence the application I just finished. The application was built to help us unify our broad code base of 100s of applications writen by various developers over time. Specifically to find and replace connection strings and hard coded server references. For .configs, its easy, File.ReadAllText() and use RegEx, done... for Binaries ( DLL / EXE primarily ) it was a little more difficult. I need to search binaries because some applications we do not control the source for and would have to request a change from that company division.
For small files I did the following:
<br />
Byte[] fileData = File.ReadAllBytes(file.FullName); <br />
String fileAsString = System.Text.Encoding.Unicode.GetString(fileData);<br />
For larger files I did the below, taken from a suggestion on this site:
String line = null;
int lineNum = 0;
using (Stream stream = file.Open(FileMode.Open, FileAccess.Read))
{
byte[] readBuffer = new byte[16384];
int bytesRead = 0;
int offset = 0;
long filePos = 0;
while ((bytesRead = stream.Read(readBuffer, offset,
readBuffer.Length - offset)) > 0)
{
line = System.Text.Encoding.Unicode.GetString(readBuffer);
MatchCollection matches = regEx.Matches(line);
if (matches.Count > 0)
{
foreach (Match match in matches)
{
if (match.Success)
{
StoreMatch(match.Captures[0].Value);
}
}
}
filePos = stream.Position;
offset = (task.Search.Replacement.Length * 2);
for (int i = 0; i < offset; i++)
readBuffer[i] = readBuffer[readBuffer.Length - offset + i];
}
}
Here are the methods used to iterate thru a "Task" for a search location
private static TaskSearchResult SearchUNC(TaskSearch task)
{
if (!task.Location.Equals(_location))
{
_location = task.Location;
_locationFilePath = new DirectoryInfo(task.Location.Path);
}
task.Search = new SearchRegEx(task.Search);
TaskSearchResult taskResult = new TaskSearchResult();
taskResult.Result = true;
if (_locationFilePath.Exists)
{
taskResult.Combine(SearchFileLocation(_locationFilePath, task));
}
else
{
taskResult.Result = false;
taskResult.SearchResults.Add(new SearchResult(task.Location.Path, String.Format("Directory {0} does not exist", task.Location.Path)));
}
return taskResult;
}
private static TaskSearchResult SearchFileLocation(DirectoryInfo directory, TaskSearch task)
{
TaskSearchResult taskResult = new TaskSearchResult();
Console.WriteLine("* File Location being searched {0}", directory.FullName);
try
{
FileInfo[] files = directory.GetFiles(task.Location.Filter, SearchOption.TopDirectoryOnly);
foreach (FileInfo fi in files)
{
try
{
if (IsTextFile(fi))
{
taskResult.Combine(SearchFile(fi, task));
}
else
{
if (fi.Length > (1024 * 1024))
taskResult.Combine(SearchFileBinaryLarge(fi, task));
else
taskResult.Combine(SearchFileBinary(fi, task));
}
}
catch (Exception ex)
{
Console.WriteLine(String.Format("File :{0} Error: {1} \n", fi.FullName, ex.Message));
taskResult.SearchResults.Add(new SearchResult(task.Location.Path, String.Format("{0} - Error:{1}", fi.FullName, ex.Message)));
}
}
if (task.Location.IsRecursive)
{
DirectoryInfo[] directories = directory.GetDirectories();
foreach (DirectoryInfo subDirectory in directories)
{
taskResult.Combine(SearchFileLocation(subDirectory, task));
}
}
}
catch (Exception ex)
{
taskResult.SearchResults.Add(new SearchResult(task.Location.Path,String.Format("{0} - Error:{1}", directory.FullName, ex.Message)));
}
return taskResult;
}
The IsTextFile(File file) method simply does a check in the registry for the extention and it checks for known Text Type files, its good enough for the scope of this application although I would love some feed back on that as well.
In conclusion, I would love any feedback you can provide, let me know if you need to see more code.
Kind Regards,
Ryan
|
|
|
|
|
Wow, I didn't even realize how bad the performance was... I tried to read a \bin folder with 11 .dlls all under 500kb and it takes well over 15 minutes. This is running on a VM on a Blade Server. So it is definately not the environment that I can tell... absolutely insane and very frustrating.
|
|
|
|