|
thanks for your helps.
signature...
|
|
|
|
|
1. added and initialized some components, including radio buttons
// Create and initialize a GroupBox and a radio Button control.
GroupBox groupBox1 = new GroupBox();
RadioButton radio1 = new RadioButton();
RadioButton radio2 = new RadioButton();
groupBox1.Size = new Size(100,100);
groupBox1.Location = new Point(4,24);
groupBox1.FlatStyle = FlatStyle.System;
groupBox1.Text = "Engin";
radio1.Location = new System.Drawing.Point(8,24);
radio1.Size = new Size(50,20);
radio1.Text = "radio1";
radio1.Name="cb9";
radio2.Location = new System.Drawing.Point(8,64);
radio2.Size = new Size(50,20);
radio2.Text = "radio2";
radio1.Name="cb10";
groupBox1.Controls.Add(radio1);
groupBox1.Controls.Add(radio2);
2. in the button click function, added following to detect state
private void btnPF_Click(object sender, EventArgs e)
{
//DETECTING components
foreach(Control c in panel1.Controls)
if (c.Name.Equals("cb1"))
{
CheckBox lb = c as CheckBox;
if (lb.Checked)
{
//MessageBox.Show("cb1 checked", "info");
}
}
else if (c.Name.Equals("cb9"))
{
RadioButton lb = c as RadioButton;
if (lb.Checked)
{
//MessageBox.Show("radio1 checked", "info");
}
}
else if (c.Name.Equals("cb10"))
{
RadioButton lb = c as RadioButton;
if (lb.Checked)
{
//MessageBox.Show("radio2 checked", "info");
}
}
All of the components are detected properly but not the radio buttons
any help is greatly appreciated
|
|
|
|
|
If RadioButtons are contained in a GroupBox which is in a Panel , then they do not appear in the Panel.Controls collection - they are in the GroupBox.Controls collection, regardless they are also inside the Panel . Similarily, controls inside a panel do not appear in the Form.Controls collection.
By the way, I suggest comparing references instead of comparing names of controls, that is, use "c == cb10 " instead of "c.Name.Equals("cb10") ".
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Whenever i am trying to execute a select statement in a ExecuteScalar() i get the exception from subject: Object reference not set to an instance of an object.
My script is:
public int InsertRecordSP(ref invOrdenes orden)
{
Database db = new Database();
try
{
//abro la coneccion y defino el Store Procedure a utilizar
db.open("insertOrder");
//Ingreso los parametros del Store Procedure
db.setParam("lastOrder", orden.getOrden());
//Ejecuto el Store Procedure
return db.executeScalar();
}
catch (DatabaseException de)
{
log.Error("DatabaseException: " + de.Message);
}
finally
{
db.close();
}
return 0;
}
public Database()
{
// set variables
this.host = ConfigurationSettings.AppSettings.Get("sql-host");
this.user = ConfigurationSettings.AppSettings.Get("sql-user");
this.password = ConfigurationSettings.AppSettings.Get("sql-password");
this.database = ConfigurationSettings.AppSettings.Get("sql-database");
// create the SqlConnection object
String source = "server=" + host + ";uid=" + user + ";pwd=" + password + ";database=" + database;
conn = new SqlConnection(source);
}
public void open(string sprocName)
{
try
{
conn.Open();
scmd = new SqlCommand(sprocName, conn);
}
catch (Exception e)
{
throw new DatabaseException(e.Message);
}
}
public int getParam(string paramName)
{
SqlParameter sqlParam = new SqlParameter();
sqlParam.ParameterName = "@" + paramName;
sqlParam.SqlDbType = SqlDbType.Int;
return (int) sqlParam.Value;
}
public int executeScalar()
{
try
{
return (int)scmd.ExecuteScalar();
}
catch (Exception e)
{
throw new DatabaseException(e.Message);
}
}
What i am doing wrong?
Regards, Diego.
|
|
|
|
|
Hi Diego,
you should have a look at the entire exception, not just its Message.
Use ToString() instead.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
If the stored procedure insertOrder does what it name suggests, it doesn't return any result at all. The ExecuteScalar method returns null if the query doesn't return a result, so when you try to use the return value, you get that exception.
---
single minded; short sighted; long gone;
|
|
|
|
|
Why is the value of the tags not being read when the code reads System.xml.XmlTextReader.Text property?
Hence within element <column> column 1 is not being read as text
Note: "sample.xml" is not being rendered well. Tried using HTML escape characters to display a sample but it was unsuccessful. See the code below.
using System;
using System.Xml;
namespace ReadXMLfromFile
{
class Class1
{
static void Main(string[] args)
{
XmlTextReader reader = new XmlTextReader("sample.xml");
while (reader.Read())
{
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
Console.Write("<" + reader.Name);
while (reader.MoveToNextAttribute())
Console.Write(" " + reader.Name + "='" + reader.Value + "'");
Console.WriteLine(">");
break;
case XmlNodeType.Text:
Console.WriteLine (reader.Value);
break;
case XmlNodeType. EndElement:
Console.Write("");
break;
}}}}}}
(source: MSDN)
sample.xml
----------
<database schema-name="products">
<column data-type="text" name="Code" pk="true" fkreferences="Product.Code"> column 1
<column data-type="int" name="Qty"> column 2
<column data-type="currency" name="CostPrice"> column 3
<table name="ProductsInStock"> </table>
<column data-type="text" name="ProductID" pk="true"> column 1
<column data-type="text" name="Description"> column 2
<table name="Product"> </table>
------------------
-- modified at 13:26 Saturday 29th September, 2007
-- modified at 5:24 Sunday 30th September, 2007
-- modified at 5:26 Sunday 30th September, 2007
<div class="ForumSig">Jon</div>
|
|
|
|
|
SqlDataReader read = cmd.ExecuteReader();
read.Read();
photo.Visible = false;
if (read["newsPhoto"] != DBNull.Value)
{
photo.Visible = true;
photo.ImageUrl = "retriveImage.aspx?id=" + read["newId"].ToString();
}
this my code to display image
but all time enter this if statment either i upload the image or not all time he enter if statment ... where the problem ?????
Palestine
|
|
|
|
|
does the path come through from the DB ? Does it exist ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hey
does anyone know where I can find one? its just really for changing the base of and handling large integers... preferably under an MIT/BSD style licence...
thx!
|
|
|
|
|
|
thepersonof wrote: any ideas?
lots of them. It suffices to Google around.
CodeProject has a couple of articles on big integers.
GNU has a multiprecision package.
etc.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
hi all,
I am working in a windows application. i have a text say for eg,
<img src="http://static.ibnlive.com/pix/sitepix/06_2007/kumaraswamy_cm90.jpg"
alt="BACKTRACKING? Kumaraswamy says he never said he would step down on October 3."
title="BACKTRACKING? Kumaraswamy says he never said he would step down on October 3"
border="0" width="90" height="62" align="left" hspace="5&"/>
Kumaraswamy has denied reports that he would step down on October 3
i need to remove the img tag entirely and display only this part.
Kumaraswamy has denied reports that he would step down on October 3
i tried using the following regular expression to extract img tag.but its not working
Regex r=new Regex("<img[^<>]+>")
can anybody help out with this?
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
anu81 wrote: Regex r=new Regex("<img[^<>]+>")
OTOH, < and > are themselves regular expression delimiters, you'll have to escape them like
@"\<img[^\<\>]+\>"
|
|
|
|
|
Hi every body,
I want to fetch database tables from SQLSERVER DBMS and display all these tables along with their attributes using c# from which the user can select the reqiured tables and correspoding fields.two points i need to know.
1-how to retrieve "database schema" from SQLSERVER.
2-after fetching,where these tables schemas can be stored from where they can be displayed to user.
Regards,
chanzeb chaudhary.
|
|
|
|
|
What brand of SQL server are you using? Microsoft SQL Server? MySQL? Oracle? Something else?
---
single minded; short sighted; long gone;
|
|
|
|
|
SQL Server is the name of the MS product, I think it's safe to assume that's the one he means.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
I have an icon resource with various large and small sizes / colour depths. Vista and XP both support png compression on icons > 48 x 48 but if I compress these icons within the resource my application won't compile.
Error 18 'CSCA8.tmp' is not a valid Win32 resource file
Is there a workaround for this?
(Using vs 2005 by the way)
Dave
|
|
|
|
|
|
That's not C# code. Pascal?
Why do you think that the code needs to ne optimised?
---
single minded; short sighted; long gone;
|
|
|
|
|
yes, may be Pascal, because that is a test in interview. i cannot finish the test.
|
|
|
|
|
So you want someone else to finish it for you, so that you can get a job doing something that you don't have the sufficent knowledge of?
---
single minded; short sighted; long gone;
|
|
|
|
|
oh no, why do you think that? i fail. but i want to know how to optimize it?
|
|
|
|
|
svincoll4 wrote: oh no, why do you think that? i fail.
Oh, sorry. Because it's not that uncommon that people try things like that, and you didn't speak of the test in the past tense.
svincoll4 wrote: but i want to know how to optimize it?
Well, that depends on the language used, and what the rest of the code looks like.
You could perhaps use a pointer to clear the array faster. Loop unraveling is another optimising method that would simply replace the loop with 101 assignment statements.
However, the most efficient might be if the code that is going to use the array could be altered to not needing the array to be cleared at all, then the loop could simply be removed.
If it's a newly created array, it might not need clearing at all. Some languages automatically clears new arrays on creation, so clearing it again would be completely pointless.
---
single minded; short sighted; long gone;
|
|
|
|