|
hello does someone know how to put a code in one of the treeview nodes???
i want every nodes to open differennt window forms..
how can i do it??
please some sample codes.. i really appreciate it,
ginji
|
|
|
|
|
Well, I assume the nodes have a tag property. You could set that, handle the selected node changed event, check the tag and based on that, open a form.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi ginji
do not Cry too much its not good for ur health and it never make you a good developer.
check the tree node events there is event call on node click in this event
<br />
<br />
if(e.Node ==Name of the Node)<br />
{<br />
Form2 obj = new Form2();<br />
obj.Show();<br />
<br />
}<br />
wasim khan
|
|
|
|
|
i want the flag true in if condition c the if condition and c the comments plz thx
just put a button on form and past those methods
private void button2_Click(object sender, EventArgs e)
{
CheckRegistration("your email here@any.com", "your reg code here");
}
public bool CheckRegistration(string _regMail, string _regCode)
{
bool flag = false;
non = _regCode;
if (((_regMail.Length > 5) && (_regCode.Length > 7)) && GetRegCode(_regMail).Equals(_regCode))
{
flag = true;
int k = 0;
}
MessageBox.Show(flag.ToString());
return flag;
}
private static int ConvReg(char _c)
{
int num = 0x2a;
char[] chArray = new char[] {
'q', '1', 'c', 'a', 'x', 'l', '-', '7', 'u', 'd', '3', 'b', '2', '9', 'n', 'g',
'f', 'v', 't', 'j', 'k', '5', 'm', 'e', 'o', 'p', '6', '@', 's', 'i', '8', 'h',
'w', '4', 'y', '_', '0', 'r', '.', 'z'
};
for (int i = 0; i < chArray.Length; i++)
{
if (_c == chArray[i])
{
num = i;
}
}
return num;
}
public static string GetRegCode(string _regMail)
{
string str = "2X";
if (_regMail.Length > 5)
{
char[] chArray = _regMail.ToLower().ToCharArray();
int index = _regMail.IndexOf("@");
str = (((str + ConvReg(chArray[0]).ToString()) + ConvReg(chArray[1]).ToString() + ConvReg(chArray[index - 1]).ToString()) + _regMail.Length.ToString() + ConvReg(chArray[index + 1]).ToString()) + ConvReg(chArray[index + 2]).ToString() + ConvReg(chArray[_regMail.Length - 1]).ToString();
}
return str;
}
its me yami
now cheers
|
|
|
|
|
I am at a loss to understand what you're asking. Which bit of code do you have a problem with ?
If the mail address and code are long enough, then the input to the program determines if it's true or not. We can't make it true in code, without short circuiting the logic that checks if it should be true.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
theredonion wrote:
Christian Graus wrote:If the mail address and code are long enough, then the input to the program determines if it's true or not. We can't make it true in code, without short circuiting the logic that checks if it should be true.
how to do short circuit. i just want those parameters which can make if condition true is it posible please help me!
like if i send parameters (myemail@yahoo.com,abc123); if this makes the if condition true then i need these parameters how it posible or which parameters should i send which make the if condition true thx
its me yami
now cheers
Reply to the forums, don't email me.
Did you not write this code ? I'm assuming now that you've used reflection to read the registration code for a piece of software you want to steal, and you can't work out how to reverse engineer this process to do it.
If you wrote the code, then you should know how to create codes that work with it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi,
i am print concept to print the dtagrid rows.....
i am using c# coding......
while taking the print i am getting output as(givn below)....
Pepsi 500ml £1.09
coke 500ml £1.09
Fanta 500ml £1.09
Sprite 500ml .99p
but my uotput should be like the given below......
Pepsi 500ml £1.09 coke 500ml £1.09
Fanta 500ml £1.09 Sprite 500ml .99p
tell me where i have to change my coding paart:
my coding is;
public class DataGridPrinter
{
private PrintDocument ThePrintDocument;
private DataTable TheTable;
private DataGridView TheDataGrid;
public int RowCount = 0; // current count of rows;
//private const int kVerticalCellLeeway = 10;
public int PageNumber = 1;
public ArrayList Lines = new ArrayList();
int PageWidth;
int PageHeight;
int TopMargin;
int BottomMargin;
public DataGridPrinter(DataGridView aGrid, PrintDocument aPrintDocument, DataTable aTable)
{
//
// TODO: Add constructor logic here
//
TheDataGrid = aGrid;
ThePrintDocument = aPrintDocument;
TheTable = aTable;
// TheTable.Columns.RemoveAt(3);
PageWidth = 350;
TopMargin = 30;
// PageWidth = ThePrintDocument.DefaultPageSettings.PaperSize.Width;
PageHeight = ThePrintDocument.DefaultPageSettings.PaperSize.Height;
//TopMargin = ThePrintDocument.DefaultPageSettings.Margins.Top;
//TopMargin = 100;
BottomMargin = ThePrintDocument.DefaultPageSettings.Margins.Bottom;
}
public void DrawHeader(Graphics g, int ff)
{
//SolidBrush ForeBrush = new SolidBrush(TheDataGrid.HeaderForeColor);
//SolidBrush BackBrush = new SolidBrush(TheDataGrid.HeaderBackColor);
//Pen TheLinePen = new Pen(TheDataGrid.GridLineColor, 1);
StringFormat cellformat = new StringFormat();
cellformat.Trimming = StringTrimming.EllipsisCharacter;
cellformat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
int ht = ff + 2;
int columnwidth = 30;
int initialRowCount = RowCount;
// draw the table header
//float startxposition = TheDataGrid.Location.X;
float startxposition = 30;
RectangleF nextcellbounds = new RectangleF(0, 0, 0, 0);
RectangleF HeaderBounds = new RectangleF(0, 0, 0, 0);
HeaderBounds.X = TheDataGrid.Location.X;
HeaderBounds.Y = TheDataGrid.Location.Y + TopMargin + (RowCount - initialRowCount) * (TheDataGrid.Font.SizeInPoints + ht);
HeaderBounds.Height = TheDataGrid.Font.SizeInPoints + ht;
HeaderBounds.Width = PageWidth;
//g.FillRectangle(BackBrush, HeaderBounds);
for (int k = 0; k < TheTable.Columns.Count; k++)
{
string nextcolumn = TheTable.Columns[k].ToString();
//Command Line
//RectangleF cellbounds = new RectangleF(startxposition, TheDataGrid.Location.Y + TopMargin + (RowCount - initialRowCount) * (TheDataGrid.Font.SizeInPoints + kVerticalCellLeeway),
// columnwidth,
// TheDataGrid.HeaderFont.SizeInPoints + kVerticalCellLeeway);
//nextcellbounds = cellbounds;
//if (startxposition + columnwidth <= PageWidth)
//{
// g.DrawString(nextcolumn, TheDataGrid.HeaderFont, ForeBrush, cellbounds, cellformat);
//}
//startxposition = startxposition + columnwidth;
//Command LIne
}
//if (TheDataGrid.GridLineStyle != DataGridLineStyle.None)
//g.DrawLine(TheLinePen, TheDataGrid.Location.X, nextcellbounds.Bottom, PageWidth, nextcellbounds.Bottom);
}
public bool DrawRows(Graphics g, int fz)
{
int lastRowBottom = TopMargin;
int hh = fz + 60;
try
{
SolidBrush ForeBrush = new SolidBrush(TheDataGrid.ForeColor);
SolidBrush BackBrush = new SolidBrush(TheDataGrid.BackColor);
//SolidBrush AlternatingBackBrush = new SolidBrush(TheDataGrid.AlternatingBackColor);
//Pen TheLinePen = new Pen(TheDataGrid.GridLineColor, 1);
StringFormat cellformat = new StringFormat();
cellformat.Trimming = StringTrimming.EllipsisCharacter;
cellformat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit;
//int columnwidth = PageWidth/TheTable.Columns.Count;
int columnwidth = (PageWidth / TheTable.Columns.Count);
//columnwidth = 100;
int initialRowCount = RowCount;
RectangleF RowBounds = new RectangleF(0, 0, 0, 0);
// draw vertical lines
Font printFont = new Font("Arial", fz);
// draw the rows of the table
for (int i = initialRowCount; i < TheTable.Rows.Count; i++)
{
DataRow dr = TheTable.Rows[i];
int startxposition = TheDataGrid.Location.X;
//startxposition = 20;
RowBounds.X = TheDataGrid.Location.X;
RowBounds.Y = TheDataGrid.Location.Y + TopMargin + ((RowCount - initialRowCount) + 1) * (TheDataGrid.Font.SizeInPoints + hh);
RowBounds.Height = TheDataGrid.Font.SizeInPoints + hh;
RowBounds.Width = PageWidth;
Lines.Add(RowBounds.Bottom);
if (i % 2 == 0)
{
g.FillRectangle(BackBrush, RowBounds);
}
else
{
//g.FillRectangle(AlternatingBackBrush, RowBounds);
}
for (int j = 0; j < TheTable.Columns.Count; j++)
{
RectangleF cellbounds = new RectangleF(startxposition,
TheDataGrid.Location.Y + TopMargin + ((RowCount - initialRowCount) + 1) * (TheDataGrid.Font.SizeInPoints + hh),
columnwidth,
TheDataGrid.Font.SizeInPoints + hh);
//200 + kVerticalCellLeeway);
if (startxposition + columnwidth <= PageWidth)
{
g.DrawString(dr[j].ToString(), printFont, ForeBrush, cellbounds, cellformat);
lastRowBottom = (int)cellbounds.Bottom;
}
startxposition = startxposition + columnwidth;
}
RowCount++;
if (RowCount + 1 * (TheDataGrid.Font.SizeInPoints + fz) > (PageHeight * PageNumber) - (BottomMargin + TopMargin))
{
DrawHorizontalLines(g, Lines);
//DrawVerticalGridLines(g, TheLinePen, columnwidth, lastRowBottom);
return true;
}
}
DrawHorizontalLines(g, Lines);
//DrawVerticalGridLines(g, TheLinePen, columnwidth, lastRowBottom);
return false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return false;
}
}
void DrawHorizontalLines(Graphics g, ArrayList lines)
{
//Pen TheLinePen = new Pen(TheDataGrid.GridLineColor, 1);
//if (TheDataGrid.GridLineStyle == DataGridLineStyle.None)
return;
for (int i = 0; i < lines.Count; i++)
{
// g.DrawLine(TheLinePen, TheDataGrid.Location.X, (float)lines[i], PageWidth, (float)lines[i]);
}
}
void DrawVerticalGridLines(Graphics g, Pen TheLinePen, int columnwidth, int bottom)
{
//if (TheDataGrid.GridLineStyle == DataGridLineStyle.None)
return;
for (int k = 0; k < TheTable.Columns.Count; k++)
{
g.DrawLine(TheLinePen, TheDataGrid.Location.X + k * columnwidth,
TheDataGrid.Location.Y + TopMargin,
TheDataGrid.Location.X + k * columnwidth,
bottom);
}
}
public bool DrawDataGrid(Graphics g, int ff)
{
try
{
DrawHeader(g, ff);
bool bContinue = DrawRows(g, ff);
return bContinue;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return false;
}
}
}
|
|
|
|
|
Wow.
I assume your datagrid does not display this way on the form, right ?
cse.vidhya wrote: for (int i = initialRowCount; i < TheTable.Rows.Count; i++)
{
DataRow dr = TheTable.Rows[i];
int startxposition = TheDataGrid.Location.X;
What do you think this will do ? I'm suspecting it will create a new row to be printed for every row in your data set. So, it sounds like you want to change i++ to i+=2, read two rows every time, and draw them next to each other.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i gave i++ to 1+=2
but i am getting only 1st row and 3rd row .. and the 2nd row and 4th rows are not coming..
i need all the rows while printing like below
Printed out should be like
Pepsi 500ml £1.09 coke 500ml £1.09
Fanta 500ml £1.09 Sprite 500ml .99p
|
|
|
|
|
Like I said, you plain do not understand your own code.
As I said, going to i+=2 means that you're not starting a new row for every item. Now you need to add code to draw every second item on the same row, or you will plainly get every second item only printed.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
Can you please refer me to a website where I can follow an asp.net 3.5 case study from start to finish?
I have searched msdn but have not found anything yet.
Thanks
|
|
|
|
|
Check here [^]
This is C# Forum Please Post it Asp.net Forum
|
|
|
|
|
|
Wondering if anyone has a state machine diagram on how regular expressions accomplish there job?
This way i can trace the diagram given a pattern and string input.
Regex.IsMatch
Regex.Replace
Regex.Split
just for learning purposes since i want to move deeper into interpretors and compilers. I already know how to implement regex in practice.
|
|
|
|
|
The book 'mastering Regular Expressions' from O Reilly has big chapters on how it all works internally.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi, I am new to c#, but I am a vb.net programmer. I have a line
strLastServer = drowData["ServerName"].ToString;
where strLastServer is declared
string strLastServer = "";
I am getting an error on build:
Cannot convert method group 'ToString' to non-delegate type 'string'. Did you intend to invoke the method?
I looked at an article on this site which seemed to suggest what I was doing was OK, but....
What am I doing wrong?
|
|
|
|
|
In C# method calls should have parathesis/()...
You will get used to it very soon
strLastServer = drowData["ServerName"].ToString();
Software - Bundle of bugs covered with features.
|
|
|
|
|
So simple - and I have been racking my brain for hours. Thanks a million!
|
|
|
|
|
public class UserSettings
{
public UserSettings[]
{
}
}
so that I can access it like so:
Console.WriteLine(UserSetting["ITEMNAME"]);
Thank you to everyone in advance.
QMuffs
|
|
|
|
|
What are you trying to accomplish?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I think it is called an accessor to my class but I'm not sure.
Let's say I have this
UserSettings["ITEMNAME"]
When it does this I have to Validate the ItemName and return the default if it doesn't exist. I basically want the [] to act as a property in a way. Would it be an operator?
QMuffs
|
|
|
|
|
I think C# Indexers can help you. Please check this link to know more about Indexers
Indexer In C#[^]
Software - Bundle of bugs covered with features.
|
|
|
|
|
That is it. I did it before but couldn't remember how or what it was called. I was looking everywhere. You saved me from going insane. Thank you very much.
QMuffs
|
|
|
|
|
This is a strange problem to describe so you will have to bear with me! I have developed a web application using c#.net that utilises server side ASPX pages that connect to a SQL2000 database. I have been load testing my application with the Microsoft Application Test Center that comes with Visual Studio 2003, with simulated loads of 10 - 400 users.
When I run a test against my web application for upwards of 10 concurrent users I start to get strange results from the database for what should be routine queries. I execute a simple query looking for a row in a table which I know is there (100% certain!) and the query returns the results to a dataset. I then get the first datatable from the dataset and check that the dataset.rows.count variable is greater then 0. Which it always is! I then proceed to look for a column that exists in the table which I specifically selected and an exception is thrown telling me the column doesnt exist in the datatable. This is actually impossible the data is DEFINATLEY there!
I can log into SQL Query analyser as the same SQL logon that the ASPX page uses to connect and run the same query and it returns the expected results without error or anaomoly.
Once an error of this type has occured, I can replicated it upto 10 minutes after it first has happened. During this 10 minute period I can switch the SQL logon the ASPX uses and it runs fine. As soon as I switch it back to the user on which the error occured it demonstrates the same problem again. After 10 minutes the problem disappears and wont happen again until I apply a heavy load to the server.
As an important note, I have now managed to replicate an identical problem with just 2 users trying to concurrently login.
Here is the snippet of code iam using to query the database:
public static DataSet execute_DataTable(String SQL_Command_String)
{
String connectionString;
connectionString = getConnectionString(@"..\xml_Settings\DB_Connect.xml");
makeConnection(connectionString);
DataSet dsResults = new DataSet();
try
{
SqlDataAdapter dbAdapter = new SqlDataAdapter(SQL_Command_String, dbConn);
dbAdapter.Fill(dsResults, "Results");
}
catch (Exception exp)
{
throw new Exception(exp.Message + " " + exp.StackTrace, exp);
}
finally
{
dbConn.Close();
}
return dsResults;
}
This function is located in a static class in a class library that compiles to a DLL that is then referenced in my web project. Every time an ASPX page requires to query the database this method is called.
When I load test my application a typical session will involve 2000 queries in a very short period of time. This is because I use a recursive c# function for generating a tree that executes alot of SQL queries.
Iam really out of ideas here guys , does any one have any ideas? All I can think of is disposing of the dataset when iam done?
Thanks in advance!
Mike
|
|
|
|
|
Without looking too closely, it sounds like with liberal use of the static keyword you've ended up with a whole bunch of non-thread-safe code. Have a second look at your data layer and imagine how multiple simultaneous calls will affect it.
If you are dealing with trees, try querying for the entire subtree in a single recordset to speed things up. Common Table Expressions are useful for recursively pulling out data in a single query.
|
|
|
|
|