|
No problems. It's the joy of coding directly in the html textbox.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: No problems. It's the joy of coding directly in the html textbox
I messed up the "dry run".
|
|
|
|
|
List<string> ZoneCode = ReturnZoneCode("select ZoneCode from AdZone where ID = 20 and AccountID=530");
TextBox1.Text = Convert.ToString(ZoneCode.ToString());
In the code above I called the function(Note: I edited the signature) and I want to bind the returned List<string> into a textbox.
Problem what I have that the Textbox is not bounded the the value returned from the call, but it had the following:
"System.Collections.Generic.List`1[System.String]"
|
|
|
|
|
That's because ToString returns this type of information on a list. If you want to display the values, you need to actually bind to an individual item.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
Well, suppose you wanted to display a list of all of the items in a textbox, you could use:
private void BindZones(List<string> zones)
{
StringBuilder sb = new StringBuilder();
foreach (string item in zones)
{
sb.AppendFormat("{0}{1}", item, Environment.NewLine);
}
TextBox1.Text = sb.ToString();
} To be honest though - you would be better off displaying this in a ListBox rather than a Textbox.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I got a null value.
please help me to return a string and not
List<string>
I'd like to change to the previous one...
|
|
|
|
|
Your code is missing - please show it.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I want the function to return a string and not a list string
Function:
public List<string> ReturnZoneCode(string sql1)
{
using (SqlConnection con1 = new SqlConnection())
{
con1.ConnectionString = ConfigurationManager.ConnectionStrings["Connectionstring"].ToString();
using (SqlCommand cmd1 = new SqlCommand(sql1, con1))
{
con1.Open();
using (SqlDataReader dr = cmd1.ExecuteReader())
{
List<string> objList = new List<string>();
while (dr.Read())
{
objList.Add(dr["ZoneCode"].ToString());
}
return objList;
}
}
}
|
|
|
|
|
Use a StringBuilder instead of a list.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Error in insert
string a = "'msman88'";
Needed to be inserted as 'msman88'
Error :
Incorrect syntax near 'msman88'.
Line 70: cmd_Account.ExecuteNonQuery();
|
|
|
|
|
in SQL single quote's can be used to delimit string literals, so if you need them as part of your data, try one of the following:
1. use SQLParameter, which is always the better option as it prevents SQL Injection vulnerability;
2. or double the single quote(s) inside your data
Now why would you want single quotes at the extremes of your data in the first place? Maybe you are misinterpreting some piece of documentation?
|
|
|
|
|
Abdul-Rhman Alsri wrote: string a = "'msman88'";
Try string a = @"''msman88''" .
modified on Saturday, May 1, 2010 11:22 PM
|
|
|
|
|
Hi
How can i bring my graphic shape to Front of all Controls in form.
my graphic is :
private void Form1_Paint(object sender, PaintEventArgs e)
{
Pen my2 = new Pen(Color.Black, 0.1f);
my2.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
e.Graphics.DrawRectangle(my2, 99, 52, 133, 99);
}
|
|
|
|
|
Don't think you can... You cannot set the z-index of controls like on a web form for example...
Why do you need your drawing in front of other controls?
|
|
|
|
|
AFAIK you can't - a form is drawn first then the controls are drawn on the form's surface.
The easiest way to acheive what you want is probably to create a DashedRectangle control that has a transparent background and make sure that's the last control to be drawn.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hey,
Is there a way to use in a C# code the MS Dictionaries?
I want to take a word in a specific langugae and get the translation in other language...is it possible?
|
|
|
|
|
Maybe this will give you a start.
|
|
|
|
|
I am working on an application where I am using C# .net as well as ATL COM.
I have created below classes
1) Class Add, Which is created using C# .Net. And which implement Addition functionality. This class uses IAdd interface which is having Add method to perform addition. (Please note that IAdd is an com interface and we have used it by creating interop dll)
public class Add : IAdd
{
#region IAdd Members
void IAdd.Add(double P1, double P2)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
2) Class Calculate (com visible component), which is created using C# .Net. And which internally uses Class ADD to perform addition. . (Please note that ICustom is an com interface and we have used it by creating interop dll)
class Calculate : ICustom
{
#region ICustom Members
Add add = new Add ();
#endregion
#region ICustom Members
void ICustom.CustomQueryInterface(Guid id, ref object ptr)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
3) Class Client, This class is created using ATL COM, which crates the object of class Calculate as “calculate“ and then tries to retrieve interface IAdd using object calculate.
To get the IAdd interface, what I have done is I have created a Custom Interface which contain a method similar to the Query Interface () method available in the IUnknownInterface.
This interface is then implemented by the class Calculate, Now whenever client requires an IADD interface pointer; it will use ICustomInterface to retrieve it.
Please suggest:
What should be the implementation Of .CustomQueryInterface(Guid id, ref object ptr)?
Also what should be the code at client side (Client is implemented inCOM)
IDL file :
[
object,
uuid(E99CD31D-34FE-4AFF-A1E6-C438F73F685F),
dual,
nonextensible,
helpstring("ICOMClient Interface"),
pointer_default(unique)
]
interface ICOMClient : IDispatch{
[id(1), helpstring("method PerformCalculation")] HRESULT PerformCalculation(void);
};
[
object,
uuid(53F4B9FA-B6E7-42aa-939B-97B93010270F),
dual,
nonextensible,
helpstring("IAdd Interface"),
pointer_default(unique)
]
interface IAdd : IUnknown{
[id(1), helpstring("method Add")] HRESULT Add([in] DOUBLE P1, [in] DOUBLE P2);
};
[
object,
uuid(8C4DE0FA-6D4B-4c52-9E35-72D1908D3457),
dual,
nonextensible,
helpstring("ICustom Interface"),
pointer_default(unique)
]
interface ICustom : IUnknown{
[id(1), helpstring("method CustomQueryInterface")] HRESULT CustomQueryInterface(GUID id ,IUnknown** ptr);
};
|
|
|
|
|
|
Hi again
trying to create a simple video fade effect by changing the contrast value of video from 0 to -128 over a period of 2 seconds, tried using time_tick and a for loop but it didnt work as all that happened was timer started and then loop exacuted
timer set to 100 millisecs
private void timer1_Tick(object sender, EventArgs e)
{
for (int i = 0; i < -128; i--)
{
contast = i
}
}
anyone point me in right direction
thanks
|
|
|
|
|
Try this:
private int contrast = 0;
private void timer1_Tick(object sender, EventArgs e)
{
if (contrast > -128)
{
contrast--;
}
else
{
timer1.Stop();
}
}
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Hi,
having the loop execute completely within a single timer tick won't cut it; what you need is one tiny step on each of a number of timer ticks, as Griff already has shown.
FYI: that requires a small time step, probably pretty close to what your system is willing to offer through a System.Windows.Forms.Timer; see my article Timer surprises, and how to avoid them[^]
BTW: your for loop's exit condition was wrong too.
|
|
|
|
|
|
The problem is quite simple, but you need to do some thinking (and possibly studying) because it shows that you have not understood static versus instance data.
public string _variable = String.Empty;
Declares a string variable called _variable, and assigns it to empty. Because this has no prefix, this is an instance variable. I.e. it is part of your class, and each instance of the calls has a separate copy of the variable. If this were cars, it could be the Colour - your car has a different Colour from my car.
public static string Variable
{
set { _variable = value; }
get { return _variable; }
}
Declares a string property called Variable. Because this has the static prefix, this is a static variable. I.e. it is part of your class, but all instances of your class share the same value. If this were cars, it could be CountTheWheels - your car and my car always have the same number of wheels - four.
Because the property is static, and the variable it is trying to use is instance, the compiler is telling you that you need to refer to a specific instance of your class in order to access the _variable value you want. What you are trying to ask is "What colour is any car?" - which is plainly nonsense since all cars do not have the same colour.
BTW: Do not make the _variable field public - that is what the property is for. If you expose the property and the backing field, which one is the user supposed to work with? The field? The property? Both? What if the property does something with the data before assigning it to the field - like validation?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|