|
Does someone know how can i get the owner of my application(Desktop maybe is the owner but how can i retrieve this owner)
best regards
dghdfghdfghdfghdgh
|
|
|
|
|
The owner of what aspect? The desktop does house the application, but the forms of the application are not parent to any other process execpt your application. (Technically speaking may be different, either way).
Why do you want the owner?
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
hello,
when i open an extended desktop the open file dialog of my application open in the other screen.
how can i do to open the dialog and the appplication in the same desktop
10x regards
dghdfghdfghdfghdgh
|
|
|
|
|
Hi,
Does anyone have code to loop through data displayed in a datagrid and display that data in a new Excel spreadsheet?
Thanks in advance.
Mvelo Walaza
Developer
Telkom SA
|
|
|
|
|
Microsoft.Office.Interop.Excel._Application _appClass = new ApplicationClass();<br />
_appClass.Visible = true;<br />
_appClass.Caption = "Excel custom title";<br />
Microsoft.Office.Interop.Excel.Workbook wbk = _appClass.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);<br />
Worksheet obj = (Worksheet)wbk.ActiveSheet;<br />
Range r = (Range)obj.Cells;<br />
for (int i = 0; i < ((GridView)this.lsvDocumentList.View).Columns.Count; i++)<br />
{<br />
r[1, i + 1] = ((GridView)this.lsvDocumentList.View).Columns[i].Header.ToString();<br />
((Range)r.Cells[1, i + 1]).Font.Bold = true;<br />
}
The above code is using a XAML listview, so it may be slightly different with WinForms. You need to also make sure to reference the Excel dll.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi,
Thanks for the answer, but I tried to convert it and it works but strangely it only shows the headings of the datagrid. Can you tell me what causes this. Here is my code:
Microsoft.Office.Interop.Excel._Application _appClass = new ApplicationClass();
_appClass.Visible = true;
_appClass.Caption = "Excel custom title";
Microsoft.Office.Interop.Excel.Workbook wbk = _appClass.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Worksheet obj = (Worksheet)wbk.ActiveSheet;
//Range r = (Range)obj.Cells[this.lsvDocumentList.Items.Count + 1, ((GridView)this.lsvDocumentList.View).Columns.Count + 1];
Range r = (Range)obj.Cells;
for (int i = 0; i < ((DataGridView)this.dgOutput).Columns.Count; i++)
{
r[1, i + 1] = ((DataGridView)this.dgOutput).Columns[i].HeaderText.ToString();
((Range)r.Cells[1, i + 1]).Font.Bold = true;
}
Mvelo Walaza
Developer
Telkom SA
|
|
|
|
|
It only shows headers because that is the only code that I gave you. You need to add another loop after the for loop to work with the cells.
The following code is what prints the headers to the excel document. Just try to duplicate the same results through trial-and-error. I would give you the cell output code, but my code does a whole bunch of extra stuff that would be to confusing to explain If you continue to have problems with trying to create your own code 'based' on what I gave you, then post back and I'll look more into it.
<br />
for (int i = 0; i < ((DataGridView)this.dgOutput).Columns.Count; i++)<br />
{<br />
r[1, i + 1] = ((DataGridView)this.dgOutput).Columns[i].HeaderText.ToString();<br />
((Range)r.Cells[1, i + 1]).Font.Bold = true;<br />
} <br />
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi,
Thanks again for the reply.
Did you mean something like this:
for (int i = 0; i < ((DataGridView)this.dgOutput).Columns.Count; i++)
{
r[1, i + 1] = ((DataGridView)this.dgOutput).Columns[i].HeaderText.ToString();
((Range)r.Cells[1, i + 1]).Font.Bold = true;
for (int j = 0; j < ((DataGridView)this.dgOutput).Columns.Count; i++)
{
r[1, j + 1] = ((DataGridView)this.dgOutput).Columns[j].ToString();
}
}
The inner for loop does not print the cells and throws the ff exception:
HRESULT: 0x800AC472
Regards,
Mvelo Walaza
Developer
Telkom SA
|
|
|
|
|
it looks like you have the second for loop inside the first, that is not what you want to do.
Here is some pseudocode to assist you
foreach column in the data grid that contains header information
{
r[1,colIndex]=column text
}
foreach row in the data grid that contains information to write to database
{
r[row+1,1]=first column of the specified row will write its data to the excel spreadsheet
r[row+1,2]=second column of the specified row will write its data to the excel spreadsheet
}//this will increment for every row in the data grid.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Thanks a lot, this was very helpful.
Mvelo Walaza
Developer
Telkom SA
|
|
|
|
|
I have this code that will export to a CSV file. Maybe it will help.
StreamWriter sw = new StreamWriter(@"C:\EPORT\ExportFile_" + DateTime.Today.ToString("ddMMyyyy") + ".csv", false);
DataTable dt = m_dtMobEmail;
int iColCount = dt.Columns.Count;
for (int i = 0; i < iColCount; i++)
{
sw.Write(@"""{0}""", dt.Columns[i]);
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
foreach (DataRow dr in dt.Rows)
{
if (dr["Exported"].ToString() == "0")
{
for (int i = 0; i < iColCount; i++)
{
if (!Convert.IsDBNull(dr[i]))
{
sw.Write(@"""{0}""", dr[i].ToString());
}
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
}
}
sw.Close();
|
|
|
|
|
I was sure I posted this message earlier... Although it didn't show under my posts... *Shrug*
Also, there's no "Graphics" section, and it is really C# Code...
Anyways, I was chatting to a few people who refuse to use GDI+ due to it's lack of "Flashy Effects" - Tinting, Lighting, Etc.
So, I ask you now - Is it possible?
Maybe a cool fiery effect (Fantastic Flame Screensaver, Anyone?)
Post your suggestions / Code Snippets showing off your "Special Effects"
Be Creative people
- Reelix
|
|
|
|
|
If you are interested in finding out how to do flashy effects, you should think about checking out Paint.Net - its an open source alternative to PhotoShop, which as far as I am aware, is programmed with GDI+ and can produce some quite nice stuff!
Chris
|
|
|
|
|
Hi,
Any one have to help me in this regard.. please........... since new to c#.net.
thanks in advance
I have a "logging.exe.config" file in different location,
I have to
1. Load The File,
2. Read The file
3. Modify particular values.
4. Update and Save The file in the same location.
My "Logger.exe.config" looks something like this
i need to set the values like enabled,logging values to true/false,.............
Please anyone help me...............
<?xml version="1.0" encoding="utf-8"?><br />
<configuration><br />
<configSections><br />
<section name="WriterTrace2Config" type="Configuration.ConfigSectionReader, Infrastructure.Logging.Helper" /><br />
<section name="TextReaderLogConfig" type="Configuration.ConfigSectionReader, Infrastructure.Logging.Helper" /><br />
</configSections><br />
--------------<br />
---------------<br />
<Listeners><br />
<ListenerInfo Type="Infrastructure.Logging.WriterTraceListener2,Infrastructure.Logging.Listeners.WriterListener2" Enabled="true" Name="TextLogger2" /><br />
<ListenerInfo Type="Infrastructure.Logging.TextReaderLog,Infrastructure.Logging.Listeners.TextReaderLogListener" Enabled="true" Name="TextReaderLog" /><br />
</Listeners><br />
--------------<br />
---------------<br />
<WriterTraceListener2Config type="Infrastructure.Logging.WriterTraceListener2Config,Infrastructure.Logging.Library.ConfigurationManager" xmlns="http://Infrastructure/Configuration.xsd" Name="WriterLog" Filtering="false"><br />
<Storage Location="C:\Logs\WriterLog" LogFileNamePrefix="TraceLog" Logging="false" SubDirectoryNamePrefix="Writer"><br />
<HeaderText>Logging Service Helper</HeaderText><br />
</Storage><br />
</WriterTraceListener2Config><br />
<TextReaderLogListenerConfig type="Infrastructure.Logging.ListenerConfig.TextReaderLogListenerConfig, Infrastructure.Logging.Listeners.TextReaderLogListener" xmlns="http://Infrastructure/Configuration.xsd" Name="ReaderLog" Filtering="true"><br />
<Storage Location="c:\Logs\TextReaderLog" SubDirectoryNamePrefix="TextReaderLog"><br />
<HeaderText>Logging Service Helper</HeaderText><br />
</Storage><br />
</KTTextRunLogListenerConfig><br />
</configuration>
BhuMan
|
|
|
|
|
Using System.IO;
// Read The File
string thePath = "";//Path to the XML Here
StreamReader sr = new StreamReader(thePath);
string tmp = sr.ReadToEnd();
tmp = tmp.Replace("Original Value", "New Value");
sr.Close();
// Write the file
StreamWriter sw = new StreamWriter(thePath);
sw.WriteLine(tmp);
sw.Flush();
sw.Close():
Hope that helps
|
|
|
|
|
|
hi, i'm posting 'cause i have a problem i can't manage to solve...
i have a page with a row of DropDownLists, and what i want to do is this: when the user selects a value from one of the dropdowns , a new one is created under the selected, with the same values of the previous one, except for the selected one.
i know i have to write a function in c# called from OnSelectedIndexChange, but i can't understand how to create the new ddl from the code..
can anyone one help me or suggest a better way to do that?
thanks anyway, and sorry for the poor english..
bye
Kontax
|
|
|
|
|
DropDownList1_OnSelectedIndexChange
{
DropDownList2.Visible = true;
}
Crude I know, but it works
|
|
|
|
|
thanks anyway, but i think i explaned it in a wrong way...
i dont know previously the number of DDL the user needs, so i cant create them before.
suggestions?
|
|
|
|
|
private System.Windows.Forms.ListBox listBox1;
private void button1_Click(object sender, EventArgs e)
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
this.listBox1.Location = new System.Drawing.Point(0, 0);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(50, 50);
this.listBox1.Items.Add("Testing");
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.l1_SelectedIndexChanged);
this.Controls.Add(listBox1);
this.ResumeLayout();
}
private void l1_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show("It Works!");
}
Im not proud of it, but it works...
Might need some heavy modification...
|
|
|
|
|
Thanks for the answer,
it's just some days i'm working with c# so i can't understand what you wrote, anyway thank you another time, i'll try to understand and use it!
byee
|
|
|
|
|
Well, you didn't know how many ddl you will need so you can't create them in design time. What he showed you is that you can dynamically create them once you know that you need a ddl, during the post back.
|
|
|
|
|
hi..
I can't manage to work with that code...
It says that i need the System.Windows.Forms namespace. But if i include it with "using" it doesn't works, cause he can't find the system.windows namespace.
i tried to download System.Windows.Forms.dll and put it in C:\windows\assembly but nothing changed..suggestions?how can i include it?
|
|
|
|
|
hello
in my c# application and when i use the extender desktop, the open dialog box appear in the other screen of my application any idea???
best regards
dghdfghdfghdfghdgh
|
|
|
|
|
Hey Guys,
Have a look at this piece of code...
public void checkPollingTimesFromHash()
{
foreach (object TerminalID in pollTimesHash)
{
txtLog.AppendText("****** " + TerminalID + "\r\n");
foreach (object PollTime in TerminalID)
{
txtLog.AppendText(PollTime + "\r\n");
}
}
}
pollTimesHash is a hash table with an object (its a number - terminal id, its of type object cuz i assign these in a foreach obj in arraylist) as its key and an arraylist object in the value. The objects inside the arraylist are of type TimeSpan
in the block above im trying to iterate through each terminals polling times. but my IDE moans "foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'"
any ideas on how i can get my desired result?
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|