|
Hi,
i have an application (fw 2.0) with a ListView in details mode. Some of the ListViewItems have different values for ForeColor and BackColor. Running the application local, all looks fine. The ListViewItems appear with the given values for BackColor and ForeColor. Problem: When i start the app by using a terminal session (Windows Server 2003 with Citrix) the BackColor and ForeColor attributes of the ListViewItems are ignored. What can I do? I don't want to override OnDrawItem, OnDrawColumnHeader and OnDrawSubItems to solve this problem.
Thanks for any hint.
Ralph
|
|
|
|
|
heres my code, dont know what the error is all about,: can someone help me.
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
Dim int As Integer
Dim str As String
Dim colname As String
Dim col As Integer
Try
col = DataGridView1.ColumnCount
For int = 6 To col
colname = DataGridView1.Columns(int).Name
str = (colname.Substring(0, 3))
Dim i As Integer = 0
If str = "qrs" Then
For i = 0 To 10
qrs(i) = DataGridView1.CurrentRow.Cells(int).Value
totalqrs = totalqrs + qrs(i)
Next i
ElseIf str = "ars" Then
For i = 0 To 10
ars(i) = DataGridView1.CurrentRow.Cells(int).Value
totalars = totalars + ars(i)
Next i
ElseIf str = "prs" Then
For i = 0 To 10
prs(i) = DataGridView1.CurrentRow.Cells(int).Value
totalprs = totalprs + prs(i)
Next i
ElseIf str = "qps" Then
For i = 0 To 10
qps(i) = DataGridView1.CurrentRow.Cells(int).Value
totalqps = totalqps + qps(i)
Next i
ElseIf str = "aps" Then
For i = 0 To 10
aps(i) = DataGridView1.CurrentRow.Cells(int).Value
totalaps = totalaps + aps(i)
Next i
ElseIf str = "pps" Then
For i = 0 To 10
pps(i) = DataGridView1.CurrentRow.Cells(int).Value
totalpps = totalpps + pps(i)
Next i
ElseIf str = "qpe" Then
qper = DataGridView1.CurrentRow.Cells(int).Value
qper1 = qper / 100
ElseIf str = "ape" Then
aper = DataGridView1.CurrentRow.Cells(int).Value
aper1 = qper / 100
ElseIf str = "ppe" Then
pper = DataGridView1.CurrentRow.Cells(int).Value
pper1 = qper / 100
ElseIf str = "per" Then
PERS = DataGridView1.CurrentRow.Cells(int).Value
ElseIf str = "mer" Then
MERS = DataGridView1.CurrentRow.Cells(int).Value
ElseIf str = "pfr" Then
PFERS = DataGridView1.CurrentRow.Cells(int).Value
ElseIf str = "fer" Then
FERS = DataGridView1.CurrentRow.Cells(int).Value
ElseIf str = "pep" Then
PEPS = DataGridView1.CurrentRow.Cells(int).Value
ElseIf str = "mep" Then
MEPS = DataGridView1.CurrentRow.Cells(int).Value
ElseIf str = "pfp" Then
PFEPS = DataGridView1.CurrentRow.Cells(int).Value
ElseIf str = "fep" Then
FEPS = DataGridView1.CurrentRow.Cells(int).Value
Else
MsgBox(" nothing to compute")
End If
Next int
WQ = ((totalqrs / totalqps) * 100) * qper1
WA = ((totalars / totalaps) * 100) * aper1
WP = ((totalprs / totalpps) * 100) * pper1
CS = Math.Round((WQ + WA + WP), 2)
WCS = Math.Round((CS * 0.4), 2)
'Preliminary
WPE = ((PERS / PEPS) * 100) * (0.1)
'Midterm
WME = ((MERS / MEPS) * 100) * (0.2)
'Pre-Final
WPFE = ((PFERS / PFEPS) * 100) * (0.1)
'Final
WFE = ((FERS / FEPS) * 100) * (0.2)
CFRS = Math.Round((WCS + WPE + WME + WPFE + WFE), 0)
'Display Weighted Exam Scores
Information.txtWPre.Text = Math.Round(WPE, 2)
Information.txtWMid.Text = Math.Round(WME, 2)
Information.txtWPf.Text = Math.Round(WPFE, 2)
Information.txtWFin.Text = Math.Round(WFE, 2)
'Display CS/CFRS
Information.lblcfrs.Text = CFRS
txtcfrs.Text = CFRS
txtCs.Text = CS
Catch ex As Exception
MsgBox(ex.Message)
End Try
it seems that the conditions arent tested, it proceeds to the "else" value..
then the error of index out of range follows..
|
|
|
|
|
Set a breakpoint at the start of this method, and then step through it keeping a careful eye out on which statement you are on, and what the value of the variables are. When it hits the exception - you'll know what caused it.
|
|
|
|
|
let the computer do the work!
|
|
|
|
|
Luc Pattyn wrote: let the computer do the work!
Nah. Let him learn how to debug a session and inspect code values.
|
|
|
|
|
Hi,
a few decades ago people invented line numbers for easily pinpointing a problem, hence:
- tell your IDE to always show line numbers in the editor windows (Visual Studio, see Tools/Options menu)
- always look at Exception.ToString() and not just Exception.Message
Taken together you will know right away what line bombs, chances are you will immediately know why too.
|
|
|
|
|
Hi,
I want to login though yahoo in .net windows application.
After login i want to search selected Yahoo Group member email id and
getting the email id want to sent mail to all group member.
i want to Yahoo API for Search group member email id.
and Yahoo API for sent email .
I want to done this work in .net windows application with c#
Please any one help me.
Thanks
|
|
|
|
|
is it possible to stop the flow of the project?
i get error and it is catched in try catch block...
after that i don't want to continue...
i want transfer the flow to my starting page...
how can i do this...
|
|
|
|
|
If it's a method you add for example return the the end of the catch block if there are statements outside the try-chatch structure. However, finally portion will still be executed. Then on the calling side you must handle this situation so that you don't continue there and so on.
|
|
|
|
|
actually it is a connection coding...
(i got error in this) i catch this but... control transfered to original form...
connection coding functuion written in class file..
this connection coding function is called in remaining forms...
|
|
|
|
|
Can you post the code? It doesn't matter what you do in the code, but it's important that you model the flow so that methods exit nicely and the calling method understands not to continue with execution. But as said, it's a bit hard to say more without the code.
|
|
|
|
|
// written in class file
public void mthOpenConnection()
{
try
{
string[] datasource = File.ReadAllLines("d:\\k2.txt");
if (datasource[0] != "")
{
objprop.connection = "Data Source=" + datasource[0] + ";Initial Catalog=Inventory_VS;User ID=sa;Password=sa";
objCon = new SqlConnection(objprop.connection);
if (objCon.State != ConnectionState.Open)
{
objCon.Open();
}
}
}
catch
{
MessageBox.Show("ENTER CORRECT DATA SOURCE NAME IN UR TEXT FILE");
}
}
// this is my login form here i call my open connection
public DataSet mthGetLogin(Properties objproperties)
{
objDBconnection.mthOpenConnection();
SqlDataAdapter objDALogin = new SqlDataAdapter("sp_login", objDBconnection.objCon);
objDALogin.SelectCommand.Parameters.Add(new SqlParameter("@uname", objproperties.Username));
objDALogin.SelectCommand.Parameters.Add(new SqlParameter("@pword", objproperties.Password));
objDALogin.SelectCommand.CommandType = CommandType.StoredProcedure;
objDALogin.Fill(objDSLogin);
return objDSLogin;
}
|
|
|
|
|
Okay, you could use for example bools:
public bool mthOpenConnection()
{
try
{
string[] datasource = File.ReadAllLines("d:\\k2.txt");
if (datasource[0] != "")
{
objprop.connection = "Data Source=" + datasource[0] + ";Initial Catalog=Inventory_VS;User ID=sa;Password=sa";
objCon = new SqlConnection(objprop.connection);
if (objCon.State != ConnectionState.Open)
{
objCon.Open();
}
}
}
catch
{
MessageBox.Show("ENTER CORRECT DATA SOURCE NAME IN UR TEXT FILE");
return false;
}
return true;
}
and then
public DataSet mthGetLogin(Properties objproperties)
{
if (!objDBconnection.mthOpenConnection())
{
return null;
}
SqlDataAdapter objDALogin = new SqlDataAdapter("sp_login", objDBconnection.objCon);
objDALogin.SelectCommand.Parameters.Add(new SqlParameter("@uname", objproperties.Username));
objDALogin.SelectCommand.Parameters.Add(new SqlParameter("@pword", objproperties.Password));
objDALogin.SelectCommand.CommandType = CommandType.StoredProcedure;
objDALogin.Fill(objDSLogin);
return objDSLogin;
}
|
|
|
|
|
it works fine...
but the flow didn't stoped bcz next consequetive lines needs valid open connection...
(but i catch invalid connection in my try block)(contradictory)
it ends in error...
|
|
|
|
|
If you added the modification to mthGetLogin that I wrote, the execution in that method won't continue because I added return null to it. However, this is only part of your code so you must use this idea in all places where you want to 'break' the execution
|
|
|
|
|
s u r right...
see this peace of code...
this is my loging forms's button(submit) click event...
when the program try to read table values error occurs...
private void button2_Click_1(object sender, EventArgs e)
{
objproperties.Username = txtuname.Text;
objproperties.Password = txtpword.Text;
objDSLogin = objfunction.mthGetLogin(objproperties);
if (objDSLogin.Tables[0].Rows.Count > 0)
{
if (objDSLogin.Tables[0].Rows[0]["status"].ToString() == "User")
{
objproperties.Username = txtuname.Text;
objfunction.mthUsernameInsert(objproperties);
this.Hide();
UserForm uf = new UserForm();
uf.Show();
}
else if (objDSLogin.Tables[0].Rows[0]["status"].ToString() == "Admin")
{
this.Hide();
AdminForm1 af = new AdminForm1();
af.Show();
}
else
{
label4.Text = "Login Failed... Try Again";
label4.Visible = true;
txtpword.Text = "";
txtuname.Focus();
}
}
else
{
label4.Visible = true;
txtpword.Text = "";
txtuname.Focus();
}
}
|
|
|
|
|
So based on the previous example I wrote, you could:
...
objproperties.Password = txtpword.Text;
objDSLogin = objfunction.mthGetLogin(objproperties);
if (objDSLogin == null)
{
return;
}
if (objDSLogin.Tables[0].Rows.Count > 0)
{
...
|
|
|
|
|
is anyother way available....
like goto,break,Abandon...
|
|
|
|
|
goto can go only to a specific point inside a method. break exits a loop so there's no quick way to do this. One way is to throw an exception inside a catch. Then catch this exception at the level you want.
|
|
|
|
|
how i can do this...
guide me..
|
|
|
|
|
public bool mthOpenConnection()
{
try
{
objprop.J = 0;
string[] datasource = File.ReadAllLines("d:\\k2.txt");
if (datasource[0] != "")
{
objprop.connection = "Data Source=" + datasource[0] + ";Initial Catalog=Inventory_VS;User ID=sa;Password=sa";
objCon = new SqlConnection(objprop.connection);
if (objCon.State != ConnectionState.Open)
{
objCon.Open();
}
}
}
catch (Exception ex)
{
MessageBox.Show("ENTER CORRECT DATA SOURCE NAME IN UR TEXT FILE");
return false;
}
return true;
}
how i can throw my exceptions....
|
|
|
|
|
how 2 display message to user in class file...(windows app using c#)
messagebox.show is not working.
|
|
|
|
|
In c#, MessageBox.Show() should work. Check the case of the statement you have. C# is case sensitive.
Bhaskara
|
|
|
|
|
in c# message box is working. it is not a problem. im using it in class file..
|
|
|
|
|
You cannot have a messagebox displayed in a class file.
Bhaskara
|
|
|
|