|
Hi,
Can U please send me some sort of rough code, so i may modify and make it.
It may help me.
Thank U.
Shiva
|
|
|
|
|
Code that does what?
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
|
I think you missunderstood me. I didn't write a program that would manually draw the tree, I just used the TreeView control.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Ok, Sorry i misleaded
Thank U
|
|
|
|
|
Hello,
I am stuck on a Collection class in which my code is apparently overwriting the previous entries whenever an 'Add' is performed. I imagine I am overlooking something or implementing something incorrectly, but I have been unable to locate my problem. Any assistance will be greatly appreciated.
Note that I fealt this was a problem with the instantiation of the item contained within the collection class, but I create a new instantiation within the while loop. Additionally, I have tried this from outside the class and within the class. The class is to determine the email addresses and group names contained within a comma-delimited string of text ( in this case the txt_To.Text ).
The code that I feel to be relevant ( though it may be too much ) is as follows:
Collection Class code:
using System;
using System.IO;
using System.Collections;
namespace Direct_Mailer.Classes
{
public class Address_List : CollectionBase
{
private static string
_Name = null;
public Address_List()
{
}
public Address_List( string Name )
{
_Name = Name;
}
#region Address List Methods
#region Standard Methods
public Address this[ int index ]
{
get
{
return ( Address )List[ index ];
}
set
{
List[ index ] = value;
}
}
public int Add( Address value )
{
try
{
return List.Add( value );
}
catch( Exception this_Exception )
{
throw new Exception( "Add to the Address List failed.", this_Exception );
}
}
public void Insert( int index, Address value )
{
try
{
List.Insert( index, value );
}
catch( Exception this_Exception )
{
throw new Exception( "Insertion into the Address List failed.", this_Exception );
}
}
public void Remove( Address value )
{
try
{
List.Remove( value );
}
catch( Exception this_Exception )
{
throw new Exception( "Removal from the Address List failed.", this_Exception );
}
}
public int IndexOf( Address value )
{
try
{
return List.IndexOf( value );
}
catch( Exception this_Exception )
{
throw new Exception( "Attempt of IndexOf failed in Address List.", this_Exception );
}
}
public void CopyTo( Address[] Address_Array, int index)
{
try
{
List.CopyTo( Address_Array, index );
}
catch( Exception this_Exception )
{
throw new Exception( "The CopyTo method failed in Address List.", this_Exception );
}
}
#endregion
#region Class Specific Methods
public string Name
{
get
{
return _Name;
}
set
{
_Name = value;
}
}
static private Address this_Address = new Address();
public Address_List generate_List( string comma_delim )
{
int begin_pos = 0,
comma_pos = 0,
amp_pos = 0;
try
{
while( comma_pos >= 0 )
{
comma_pos = comma_delim.IndexOf( ',', comma_pos );
if ( comma_pos <= 0 )
this_Address.address = comma_delim.Substring( begin_pos);
else
this_Address.address = comma_delim.Substring( begin_pos, comma_pos - begin_pos );
this_Address.address.Trim();
amp_pos = this_Address.address.IndexOf( '@' );
if ( amp_pos != -1 )
this_Address.type = Address.Type.Address;
else
this_Address.type = Address.Type.Group;
List.Add( this_Address );
if ( comma_pos >= 0 )
begin_pos = amp_pos = ++comma_pos;
}
return this;
}
catch( Exception this_Exception )
{
throw new Exception( "Error occured attempting to generate an Address List.", this_Exception );
}
}
#endregion
#endregion
}
}
From the item class the Collection class contains:
using System;
using System.IO;
namespace Direct_Mailer.Classes
{
public class Address
{
public Address()
{
}
public enum Type
{ Address, Group };
private static string
_address = null;
public string address
{
get
{
return _address;
}
set
{
_address = value;
}
}
private static Type _type = 0;
public Type type
{
get
{
return _type;
}
set
{
_type = value;
}
}
}
}
From the function on the form that accesses the collection:
private void btn_Send_Click(object sender, System.EventArgs e)
{
Address_List To_List = new Address_List();
if ( txt_To.Text.Length <= 0 )
{
MessageBox.Show("This email has not been addressed to anyone", "Direct Mailer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
txt_To.BackColor = Color.LightCoral;
return;
}
To_List.generate_List( txt_To.Text );
txt_Body.Text = "Listing produced the following:";
for ( int counter = 0; counter < To_List.Count; counter++ )
{
txt_Body.Text += "\n\t" + To_List[ counter ].address
+ "\t" + To_List[ counter ].type.ToString();
}
}
Far better to keep one's mouth shut
_ and appear stupid
than to open one's mouth
_ and remove all doubt.
I rarely follow this.
|
|
|
|
|
I’m new to .NET and HTML programming …
I’m trying to automatically (programmatically) select an entry in a HTML table. I’m using C# and .NET and the WebBrowser Class.
I can automatically log in by doing
HtmlElement userElem = doc.GetElementById("signin:user");
userElem.InnerText = this.m_username.Text;
HtmlElement pwElem = doc.GetElementById("signin:password");
pwElem.InnerText = this.m_password.Text;
HtmlElement btnElem = doc.GetElementById("signin:signinbtn");
btnElem.InvokeMember("click");
I have a table I need to process which looks like:
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td class="TopBorder"></td>
<td class="TopBorder" align="right" width="1000"></td>
<td class="TopBorder" vAlign="top" align="right" width="1"></td>
</tr>
<tr height="6">
<td></td>
</tr>
<TR>
<TD vAlign="top" width="1" rowSpan="3">
<SELECT size="2" onchange="UpdateTable(event)" style="FONT-SIZE: xx-small; WIDTH: 200px; font-family: Verdana, Helvetica, sans-serif;"
id="lbInList">
<OPTION style="BACKGROUND-COLOR: LemonChiffon" value="303294000">OPTION 1 </OPTION>
<OPTION style="BACKGROUND-COLOR: PaleGreen" value="366779420">OPTION 2 </OPTION>
</SELECT>
</TD>
</TR>
</TABLE>
Ive tried but get no selection: Any ideas what i'm doing wrong?
HtmlElement Table = doc.GetElementById("Table1");
HtmlElement Info = doc.GetElementById("lbInList");
Info.SetAttribute("value", "303294000");
Info.InvokeMember("select", "1");
|
|
|
|
|
In JavaScript you would have to set the OPTION's selected property to true.
|
|
|
|
|
Thanks! & One step closer
HtmlElement Table = doc.GetElementById("Table1");
HtmlElement Info = doc.GetElementById("lbInList");
Info.SetAttribute("selectedIndex", "4");
Info.InvokeMember("change");
Now yields the 4th item being selected, but the "onchange" event doesn't seem to fire. Ive tried
Info.InvokeMember("click"); as well but it doesnt invoke the onchange="UpdateTable(event)" script.
Any more insight?
|
|
|
|
|
Hi!
I have a file (input.txt) which contains:
1 2 7 4 5
6 7 8 9 0
33 64 0 6 7
I want to read this file's contents and sort each row by increasement. Then write again in a new file (output.txt)which will contain:
1 2 4 5 7
0 6 7 8 9
0 6 7 33 64
Thanks!
|
|
|
|
|
And what is the problem?
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
using System;
using System.IO;
namespace MyApplication
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
if(File.Exists("output.txt"))
{
File.Delete("output.txt");
}
StreamReader streamReader = new StreamReader("input.txt");
StreamWriter streamWriter = new StreamWriter("output.txt");
while(true)
{
try
{
string[] texts = streamReader.ReadLine().Split(' ');
int[] numbers = new int[texts.Length];
for(int i = 0; i < texts.Length; i++)
{
numbers[i] = Int32.Parse(texts[i]);
}
Array.Sort(numbers);
string newString = "";
for(int i = 0; i < numbers.Length; i++)
{
newString += numbers[i].ToString();
if(i != numbers.Length - 1)
{
newString += " ";
}
}
streamWriter.WriteLine(newString);
}
catch
{
break;
}
}
streamReader.Close();
streamWriter.Close();
}
}
}
|
|
|
|
|
I'm trying to get the document properties: Title, Author, etc of a document. I can find great documentation on Microsoft Office documents, but I need to do it for all documents. I think the solution will use the MODI library. Any help is greatly appreciated.
|
|
|
|
|
I'm in the process of building my first n-tier software package. However I'm kind of stuck on a design decision. I posted in the C# forum since this is the language I am using, however the responses will most likely be algorithmic and language agnostic.
So here is the issue (VERY basic) I'm sure...
Each user needs to be logged into the program in order to use it. I'm going to use a basic username/password authentication scheme however, how would I implement this? I've never done anything like this before and I am not a professional. My first idea was to keep a SQL2005 table of users with information for each user such as password and other personal information. I was going to use SqlCommand() to do a select query where the username and password match on a character by character basis. Is this the best, or at least an "ok" way to do this? How is authentication "normally" implemented using .NET?
Thanks,
John
|
|
|
|
|
I am not sure I would say anything is the normal way.
Username/Password is common, but never store or send the password in clear text. Encrypt it in some way, MD5 hash is common but can be broken (as most methods can be. Another option is if all machines are on the same domain. Use windows authentication, this fails if users leave and do not password lock their machines however. In some cases I have also read machine information (mac address, etc.) and allow user X to only come via machine y. Depends on what you are looking for.
In any event, along with the username/password fields have fields for last login time/date and number of login failures. If unused for x days, lock the account or if x unsuccessful attempts also lock the account.
"Every new day begins with possibilities. It's up to us to fill it with things that move us toward progress and peace.” (Ronald Reagan)
|
|
|
|
|
|
Why not just require they log into their Windows account and assume they are therefore authenticated?
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi,
I have a ListBox bound to a DataTable in a Win Form (DataTable populated from a MS Access database). I want the user to be able to change the position of the items in the ListBox and then save back to database in the updated order (or maybe tagged for a sort order).
Would the first step of resorting the items in the ListBox be to change the order of the rows in the DataTable? If so, how would this be done?
Would the second step (saving the list back to the database file), be to delete all rows in the MS Access table and then Insert the complete updated DataSet (achieving the correct order)?
Or, should I be adding a new column like "SortOrder" and populating this with the ListBox's index numbering? I guess this column (for all rows) would have to be updated every time an item is moved or deleted in the ListBox(DataTable).
Any ideas on how to work this out would be appreciated.
Ron
|
|
|
|
|
myNameIsRon wrote: Or, should I be adding a new column like "SortOrder" and populating this with the ListBox's index numbering? I guess this column (for all rows) would have to be updated every time an item is moved or deleted in the ListBox(DataTable).
That sounds like the way to go. Since the list is bound, you can't really mess around with the order that the items appear, unless you change the sort order. Also, when storing rows in the DB you should not depend on the physical order of the rows to preserve the sort order. Keeping that information in a separate column is the best way to keep track it.
Josh
-- modified at 7:30 Tuesday 2nd May, 2006
|
|
|
|
|
Thanks Josh!
Ya, you don't really want to muck with the original ID's.
Ron
|
|
|
|
|
I am experimenting with the datagrid and have not found two issues (they are related so if I find one, I may have a working solution.)
One is I can not find what keydown event I need to handle to capture the arrow keys. The left and right arrows are events in the individual cells if you are moving the cursor along the characters (in a textbox) but the up and down or the left and right are not captured when moving which cell is selected. They are also not key events of the datagrid. What item/component are the arrow key down events associated with?
Alternately I could handle the current cell changing and keep track of the last and next cells. For then moving over a row I do not want selected I can set the selected row by using the datagrid.CurrentRowIndex. Which works fine for rows, but I find no equivalent for columns. Any suggestions on setting the current column?
Thanks for the help. Here is my sample dialg box code if any one can make use of the handling I have so far.
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
namespace TestDlg<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.Button PressMe;<br />
private System.Windows.Forms.DataGrid m_dataGrid;<br />
private System.Data.DataSet m_dataSet;<br />
private System.Data.DataTable m_dataTable;<br />
<br />
private System.Windows.Forms.DataGridCell m_CurCell;<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
m_dataTable = new DataTable("test");<br />
m_dataTable.Columns.Add("Name");<br />
m_dataTable.Columns.Add("Col-1");<br />
m_dataTable.Columns.Add("Col-2");<br />
this.SetTableStyle(m_dataGrid,m_dataTable);<br />
<br />
string[] row = new string[3] {"R-name","11111","22222"};<br />
<br />
m_dataTable.Rows.Add(row);<br />
m_dataTable.Rows.Add(row);<br />
m_dataTable.Rows.Add(row);<br />
m_dataTable.Rows.Add(row);<br />
m_dataTable.Rows.Add(row);<br />
<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.PressMe = new System.Windows.Forms.Button();<br />
this.m_dataGrid = new System.Windows.Forms.DataGrid();<br />
((System.ComponentModel.ISupportInitialize)(this.m_dataGrid)).BeginInit();<br />
this.SuspendLayout();<br />
this.PressMe.Location = new System.Drawing.Point(608, 24);<br />
this.PressMe.Name = "PressMe";<br />
this.PressMe.Size = new System.Drawing.Size(80, 64);<br />
this.PressMe.TabIndex = 0;<br />
this.PressMe.Text = "PressMe";<br />
this.m_dataGrid.DataMember = "";<br />
this.m_dataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;<br />
this.m_dataGrid.Location = new System.Drawing.Point(16, 16);<br />
this.m_dataGrid.Name = "m_dataGrid";<br />
this.m_dataGrid.Size = new System.Drawing.Size(552, 312);<br />
this.m_dataGrid.TabIndex = 1;<br />
this.m_dataGrid.KeyDown += new System.Windows.Forms.KeyEventHandler(this.m_dataGrid_KeyDown);<br />
this.m_dataGrid.MouseDown += new System.Windows.Forms.MouseEventHandler(this.m_dataGrid_MouseDown);<br />
this.m_dataGrid.Click += new System.EventHandler(this.m_dataGrid_Click);<br />
this.m_dataGrid.CurrentCellChanged += new System.EventHandler(this.m_dataGrid_CurrentCellChanged);<br />
<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(696, 341);<br />
this.Controls.Add(this.m_dataGrid);<br />
this.Controls.Add(this.PressMe);<br />
this.Name = "Form1";<br />
this.Text = "TestDlg";<br />
((System.ComponentModel.ISupportInitialize)(this.m_dataGrid)).EndInit();<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
private void SetTableStyle(DataGrid dg, DataTable dt)<br />
{<br />
try<br />
{<br />
DataGridTableStyle ts = new DataGridTableStyle();<br />
ts.HeaderForeColor = Color.Black; <br />
ts.HeaderFont = new Font("Verdana", (float)8.25); <br />
ts.MappingName = dt.TableName;<br />
ts.BackColor = Color.Linen;<br />
ts.AlternatingBackColor = Color.Aquamarine;<br />
<br />
DataGridColumnStyle cs;<br />
DataGridTextBoxColumn tbc;<br />
<br />
foreach (System.Data.DataColumn col in dt.Columns)<br />
{<br />
if(col.ColumnName.CompareTo("Name")==0)<br />
{<br />
cs = new DataGridTextBoxColumn();<br />
tbc = (DataGridTextBoxColumn) cs;<br />
cs.ReadOnly=true;<br />
}<br />
else if(col.DataType.ToString().CompareTo("System.String")==0)<br />
{<br />
cs = new DataGridTextBoxColumn();<br />
tbc = (DataGridTextBoxColumn) cs;<br />
tbc.TextBox.KeyDown += new KeyEventHandler(m_curCell_KeyDown);<br />
tbc.TextBox.MouseDown += new MouseEventHandler(m_curCell_MouseDown);<br />
tbc.TextBox.Click += new EventHandler(m_curCell_Click);<br />
}<br />
else if(col.DataType.ToString().CompareTo(DbType.Boolean.ToString())==0)<br />
{<br />
cs = new DataGridBoolColumn();<br />
((DataGridBoolColumn)cs).AllowNull = false;<br />
}<br />
else <br />
{<br />
cs = new DataGridTextBoxColumn();<br />
tbc = (DataGridTextBoxColumn) cs;<br />
}<br />
cs.HeaderText = col.ColumnName;<br />
cs.MappingName = col.ColumnName;<br />
ts.GridColumnStyles.Add(cs);<br />
if(col.ColumnName.CompareTo("Name")==0) cs.ReadOnly=true;<br />
}<br />
<br />
dg.TableStyles.Clear();<br />
dg.TableStyles.Add(ts);<br />
dg.DataSource = dt;<br />
<br />
}<br />
catch ( Exception e )<br />
{<br />
throw e;<br />
}<br />
}<br />
<br />
<br />
private void m_dataGrid_Click(object sender, System.EventArgs e)<br />
{<br />
int curr = m_dataGrid.CurrentRowIndex;<br />
}<br />
<br />
private void m_dataGrid_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)<br />
{<br />
int curr = m_dataGrid.CurrentRowIndex;<br />
}<br />
<br />
private void m_dataGrid_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
int curr = m_dataGrid.CurrentRowIndex;<br />
}<br />
<br />
private void m_dataGrid_CurrentCellChanged(object sender, System.EventArgs e)<br />
{<br />
int curr = m_dataGrid.CurrentRowIndex;<br />
curr = m_dataGrid.CurrentCell.RowNumber;<br />
if(curr==0) m_dataGrid.CurrentRowIndex = 1;<br />
int curc = m_dataGrid.CurrentCell.ColumnNumber;<br />
<br />
m_CurCell = m_dataGrid.CurrentCell;<br />
}<br />
<br />
private void m_curCell_Click(object sender, System.EventArgs e)<br />
{<br />
int curr = m_dataGrid.CurrentRowIndex;<br />
<br />
}<br />
<br />
private void m_curCell_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)<br />
{<br />
int curr = m_dataGrid.CurrentRowIndex;<br />
}<br />
<br />
private void m_curCell_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
int curr = m_dataGrid.CurrentRowIndex;<br />
<br />
}<br />
<br />
<br />
}<br />
}
"Every new day begins with possibilities. It's up to us to fill it with things that move us toward progress and peace.” (Ronald Reagan)
|
|
|
|
|
Okay, this may sound silly but I've never had to create a DLL in c# until now. I've written a C# dialog app and I want to run some crystal reports from a dll. So can someone point me to a tutorial that shows how to create dll's and how to call them from my C# app? Oh and in my dll I will need to pop up a dialog showing the report in it. Is this doable? I've done it plenty times in MFC.
Thanks
Tom Wright
tawright915@yahoo.com
-- modified at 18:12 Monday 1st May, 2006
|
|
|
|
|
If you need Win32 dll - you can't create it in c#. You have to make it in c++ or any other native language. About using Win32 dlls from c# - search for Platform Invoke (p/invoke). This can be useful, for example
If you need .net dll - just set in project properties, on Application tab, "output type" property to "Class library".
Using .net dlls on design-time is very easy - add reference to needed dll and use it through Namespace.Class.Function system. For example, if your dll contains function ShowReport() in class Report in namespace MyReportNamespace, you just have to call for MyReportNamespace.Report.ShowReport().
About showing dialog - I don't know what about CrystalReport, but I've used a lot of forms, called from dlls.
____________________________________________
Robin Panther http://www.robinland.com
|
|
|
|
|
I've tried to use this method just as I see it after Googling every way I can find, and the usage is all the same:
string strCompressed = PassportIdentity.Compress(strToCompress);
But when I try to use it, I get an exception: "Unable to load dll (aspnet_isapi.dll)". I added a reference to System.Web and a using directive for System.Web.Security, and it just won't work. Any clues as to what I'm screwing up?
My Music | My Pics | My Articles
BlackDice
|
|
|
|
|
1) Are you trying to use it in ASP.NET with Microsoft IIS installed?
2) How are you trying to use it?
--
I've killed again, haven't I?
|
|
|
|