|
if (string.IsNullOrEmpty(textBox1.Text)) {
MessageBox.Show("Please enter some data.");
} else if (!IsValidInput(textBox1.Text)) {
MessageBox.Show("Not a valid input.");
} else {
your code...
}
Write a method IsValidInput that queries the database to find out if the input is valid and returns true or false accordingly.
|
|
|
|
|
Hi, I have a word document where I have put many shapes and equations. I am reading and modifying that document through the c# code. Now I need to hide/show those shapes according to different criteria. Can anyone let me know the solution.
Pankaj
|
|
|
|
|
Hi
I add a panel to my form in code behind.
how can i set background of panel in code behind?
how can i add this panel to my form in code behind?
THX alot
|
|
|
|
|
Try doing it in the designer and then looking at the code the designer generates.
However, remember to set the size and location as well. E.g. :
Panel mypanel = new Panel();
mypanel.BackColor = System.Drawing.Color.Red;
mypanel.Size = new System.Drawing.Size(100,200);
mypanel.Location = new System.Drawing.Point(10,10);
this.Controls.Add(myPanel);
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
Hi everyone...
I'm using an SQL Server Compact Edition
I can do all the queries without a problem but I cannot create a table.
in the runtime, when it comes to create a table, the line of the "ExecutNonQuery" gives an error:
"There was an error parsing the query [Token line number=1, Token line offset = 14]..etc"
I now that this kind of error appears when your SQL command syntax is wrong
can anybody tell me what is my fault?
string CreCom = "CREATE TABLE " + TCkim + YilBox.Text + " (Aylar nvarchar (10), Statu nvarchar (20), Odeme nvarchar (20), Servis nvarchar (20), Kiyafet nvarchar (20), Kitap nvarchar (20), Tiyatro nvarchar (20), Sinema nvarchar (20), Yemek nvarchar (20), Muze nvarchar (20), Piknik nvarchar (20), Parti nvarchar (20), Diger nvarchar (20), Yoklama nvarchar (20), Aylik nvarchar (20), Odenen nvarchar (20), Kalan nvarchar (20))";
SqlCeCommand CreateCommand = new SqlCeCommand(CreCom, conn);
CreateCommand.ExecuteNonQuery();
note: SqlCeCommand is the "SqlCommand" for Compact Edition. Usage is all the same
|
|
|
|
|
BTW
my CreCom string is created as below in the runtime:
"CREATE TABLE 444442009 (Aylar nvarchar (10), Statu nvarchar (20), Odeme nvarchar (20), Servis nvarchar (20), Kiyafet nvarchar (20), Kitap nvarchar (20), Tiyatro nvarchar (20), Sinema nvarchar (20), Yemek nvarchar (20), Muze nvarchar (20), Piknik nvarchar (20), Parti nvarchar (20), Diger nvarchar (20), Yoklama nvarchar (20), Aylik nvarchar (20), Odenen nvarchar (20), Kalan nvarchar (20))"
is there something wrong?
|
|
|
|
|
well,
I just found out that when I put an "a" to the beginning of the table name, this problem is no more
but still, thank you all =)
|
|
|
|
|
a table name is an identifier, it cannot start with a digit. Similar to most programming languages.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
table A
Field: a(char(40)) b(char(40))
q -- ss
q -- fs
q -- ffr
q -- egg
w -- ffh
w -- gykk
e -- hrh
e -- kyk
e -- jjtj
the Purpose: field "a" as father node,field "b" as child node,field "a" should not be repeated!this is part of my code,but it can't meet my Requirements.
public void AddTree(TreeNode pNode)
{
DataSet ds=new DataSet();
DataView dvTree = new DataView(ds.Tables[0]);
foreach (DataRowView Row in dvTree)
{
if (pNode == null)
{ //add father node
TreeNode Node = treeView1.Nodes.Add(Row["a"].ToString());
}
else
{
TreeNode Node = pNode.Nodes.Add(Row["b"].ToString());
}
}
it only can show feild "a" on treeview,like this:
q
q
q
q
w
w
e
e
e it repeat the Field 'a',can someone help me ,thanks very much!! always waiting online
|
|
|
|
|
Looking at the sample you've posted, pNode will always be null, hence the reason a is shown again and again. What you need to do is:
if (pNode == null)
{
pNode = treeView1.Nodes.Add(Row["a"].ToString());
}
else
{
TreeNode Node = pNode.Nodes.Add(Row["b"].ToString());
}
"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 get the Results like
q(father node)
..ff(child node)
..grt
..trt
..hth
w
..trt
..fgh
..hth
e
..htj
..htr
..trt
..ht
which is your changed code shown:
q(father node)
..ff(child node)
..grt
..trt
..hth
..trt
..fgh
..hth
..htj
..htr
..trt
..ht
if do thisif (pNode == null){ //add father node pNode = treeView1.Nodes.Add(Row["a"].ToString());}else{ TreeNode Node = pNode.Nodes.Add(Row["b"].ToString());} pNode=null;
shown only father node like:
q
w
e
|
|
|
|
|
To be honest, your logic has more fundamental problems. You have two columns here which you are trying to work with, but the logic you have in the if/else only applies to one column level. What you could do is reimplement your logic like this:
foreach (DataRow dr in ds.Tables[0])
{
string colName = dr["a"].ToString();
TreeNode node = treeView1.Find(colName);
if (node == null)
{
node = treeView1.Nodes.Add(colName, colName);
}
node.Nodes.Add(dr["b"].ToString());
} What you are doing here is adding a node with a specific key into the treeview - and this key is the value of column a. You look for this node using the Find method and add it in if it doesn't exist. Finally, you add column b to the node.
"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
|
|
|
|
|
thanks for you,but when runing the code you have give me it shows:
"System.Windows.Forms.TreeView" does not contain a "Find" Definition?
|
|
|
|
|
i want get the Results like
q(father node)
..ff(child node)
..grt
..trt
..hth
w
..trt
..fgh
..hth
e
..htj
..htr
..trt
..ht
which is your changed code shown:
q(father node)
..ff(child node)
..grt
..trt
..hth
..trt
..fgh
..hth
..htj
..htr
..trt
..ht
if do this
if (pNode == null)
{ //add father node
pNode = treeView1.Nodes.Add(Row["a"].ToString());
}
else
{
TreeNode Node = pNode.Nodes.Add(Row["b"].ToString());
}
pNode=null;
shown only father node like:
q
w
e
|
|
|
|
|
table A
Field "stuage"
15 15 16 17 15 16 17 18 15 16 17 18
if do this:select * from A it show:15 15 16 17 15 16 17 18 15 16 17 18
but how can make it show:15 16 17 18,not repeat!
thanks
|
|
|
|
|
I suggest you buy a basic book on SQL and read it. And post SQL questions in the SQL forum in future.
Look up the SQL keyword 'distinct'
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I need the window form to hide itself when the user clicks [x] close button in the upper right corner.
Thus it will reside allocated and once user clicks to open it, it will just become visible again.
But upon main program termination it needs to be closed in any case.
[x] button click results in form deallocation.
Чесноков
|
|
|
|
|
HAndle the form closing event, set the flag on the event args to stop it closing, and hide it. Add your own flag that gets checked so you can close it in code.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Many thanks.
There is also CloseReason available in closing event.
In Borland Builder it was possible to define which forms should remain through out application life cycle.
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: I need the window form to hide itself when the user clicks [x] close button in the upper right corner
Is that what the user needs and expects?
Chesnokov Yuriy wrote: upon main program termination
And clicking the [x] is one way the user expects to do that.
Chesnokov Yuriy wrote: [x] button click results in form deallocation.
No it doesn't. That's up to the Application.
|
|
|
|
|
1. Which is the country hosting the 2012 Olympic Games?
(a)Portugal
(b)India
(c)South Korea
(d)England
(d)England
2. What is the largest mammal in the world?
(a)Blue Whale
(b)Elephant
(c)Camel
(d)Rhino
3. Which is the smallest ocean in the world?
(a) Arabian Ocean
(b)Pacific Ocean
(c) Artic Ocean
(d) Indian Ocean
4. The longest river in the world is the?
(a)Amazon
(b) Mississippi River
(c)Neil
(d)Brahmputra
5. The highest mountain in the world is ?
(a) Lhotse
(b) Kanchenjunga
(c) Karakoram
(d) Everest
6. The biggest desert in the world is the
(a) Arabian(Arabia)
(b) Sahara (Africa)
(c) Gobi(China)
(d) Patagonian (Argentina)
7. The largest coffee growing country in the world is
(a) Indonesia
(b) Colombia
(c) Vietnam
(d) Brazil
(e) India
8. The biggest island of the world is
a. Greenland
b. New Guinea
c. Borneo
d. Madagascar -Baffin
9. The country which is the largest producer of rubber in the world is
(a) Malaysia
(b) Thailand
(c) Zaire Republic
(d) India
|
|
|
|
|
And what has this to do with anything?
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
This is not the correct forum for these kind of posts. Try Lounge instead.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
hello every1 , am new to programming. am doin my dissertation on cd database in C#. my software should retrieve information from a cd dat is manually put into cd drive. software should copy cd info like the artist , name, song , et into a database.
This is where am stuck. am havn problems copying the cd info successfully. now my deadline is in just 1month.
This code i thought was workin.now it isnt.
PLS I NEED HELP.. AM DESPERATE..
|
|
|
|
|
Can you show the code where you are copying the CD data. And pin point the problem you are facing.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|