|
This is where I am confused I do want to pass the name of a control. My frmMain has a panel with labels on it. Each label indicates a winning hand. If a hand is won (i.e. Full House) then the label's forecolor should change from White to Yellow. Thus the hand analyzer decides if you have a full house. Then it passes the Label's Name that it wants the forecolor changed on.
Originally I thought I could use Form1.Label1 to pass the Labels name as a variable. That didn't work. So i tried Form1.Label1.Name, that passed the label's name, but as a string. I eventually settled on simply passing a string "Label1". All of these work to the point where the name is passed back to the Forms method UpdateLbls. However it is at this point that I need to be able to tell Label1.Forecolor what to do. But you cannot impliclty convert a String to Label. My book, nor the web has helped me on this matter.
|
|
|
|
|
1. in .NET a name IS a string.
2. in .NET programming you normally don't identify objects by name, you do by reference.
From what you now told, your business logic calculates a state (hand won, hand not won); so that information is what needs to be passed out towards the GUI, not a name, not a string, but either a boolean, or an enum representing all possible states (currently 2).
The next issue is, if only one hand can be winning, how and where to implement that.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Ok, after stressing you out all afternoon, I either caught a clue or took the cheap way out!
Basically, I created a method in my frmMain class. The method takes one argument, an int. The method looks at the passed variable passes through a switch block and updates the appropriate controls.
I pass the int from Hand_analyzer to results, I am using the public event EventHandler UpdateLabels; to pass the int to the frmForm class
Did I learn?
|
|
|
|
|
glad you made some progress.
yogi_bear_79 wrote: Did I learn?
I don't know; maybe yes and no, yes you learned to be creative and got it to work somehow, and no you most likely did not learn the right way to do it.
And I wouldn't say what you learned was proportional to the time invested. Really studying C# and Windows programming in a systematic way would be much more efficient. And result in much better code in the end.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
yogi_bear_79 wrote: how to conver the string into a Label.
The (VBesque) answer to your question can be found in this[^] CP article.
I would have to agree with Luc that you may want to get a better grasp of the concepts behind objects and references; this might make it a lot easier for you to implement what you want to do.
/ravi
|
|
|
|
|
Suppose the sql is :
select empno, empname, deptname,sal from emp, dept where emp.did= dept.did
I need the following:
If the column name is empno replace it by eno,
If the table name is emp then replace it by employee,
If the table is dept then replace it by department,
if the column name is did replace it by deptid.
That means after operation my the sql should be as follows:
select eno, empname, deptname, sal from employee,department where employee.deptid=department.deptid
I will be greatfull if any body help me to complete this.
I got a parser but it only can parse the column name in select statement and table names. But I am not getting the column names in the join condition. After getting the column name or table name how can I replce those?
Suppose I got emp as table but if I replace all the emp by employee then empname is also converting to employeename which is becoming to wrong column name
|
|
|
|
|
Use a Dictionary<string,string> ? Populate it with the old and new values. Split the existing statement and iterate the parts. If a part exists in the dictionary retrieve its replacement. Build a new statement.
|
|
|
|
|
I got some idea. But do you know any god parsers name where i can easily find out the column names, table names, join tables names columns in join condition, column in where clause, column in group by clause and having clause.
|
|
|
|
|
How to change color of RibbonControl, i am using RibbonControl.dll.
yogesh
|
|
|
|
|
I am not familiar with RibbonControl.dll and cannot therefore answer your question. I would suggest that you will get a better response if you ask the author of the control.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I would like to learn how to do for each. I have been researching. I also know this should be one of those no brainier questions but I am still piecing together how to make foreach for for me.
I know how to count my tables and fields then place the information in. But what I would like is to learn how to use the foreach command. to say something like.
Foreach (table in Database)
{
Foreach (column in table)
{
}
}
instead of counting the tables and columns and their names.
This will allow me to recreate a database from an existing one.
Any websites or information you can provide to point me in the right direction would be appreciated.
Just for reference purposes...
string sConnectString = "Driver={QODBC Driver for QuickBooks};DFQ=C:\\Quickbooks\\sample_company_file.qbw;OpenMode=M;OLE DB Services=-2;";
string sSQL = "SELECT Name FROM Employee";
OdbcConnection cn;
OdbcCommand cmd;
cn = new OdbcConnection(sConnectString);
cmd =new OdbcCommand(sSQL,cn);
try
{
cn.Open();
MessageBox.Show("open");
OdbcDataReader dr = cmd.ExecuteReader();
dr.GetSchemaTable().
MessageBox.Show(dr.GetSchemaTable().TableName);
}
catch (OdbcException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
cn.Close();
}
|
|
|
|
|
Not to poo-poo your question, but why are you writing code to do what sql already can?
Anyway - I'm not sure I actually get your question. If you're looking for the db/table/column structure info, you can use queries (which I'll inlcude at the end of this post) - but I'd try looking at the Interop.SQLDMO objects. Slow & a bit old-fasioned (I'm sure) but it works (I use it in a code generator I made) pretty well.
Aforementioned scripts:
-- select * From information_schema.tables -- (Tables)
-- select * From information_schema.columns -- (Columns)
-- Select * From syscolumns -- (another way to look at columns)
-- sp_fkeys([table] -- (fkeys for table)
-- SELECT FK.Table_name 'FKTableName', CU.column_name 'FKColumnName', pk.table_name 'PKTableName', pt.column_name 'PKColumnName',cu.table_catalog
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS C INNER JOIN
INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS FK ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME INNER JOIN
INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS PK ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME INNER JOIN
INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS CU ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME INNER JOIN
(SELECT i1.TABLE_NAME, i2.COLUMN_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS i1 INNER JOIN
INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS i2 ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME
WHERE
(i1.CONSTRAINT_TYPE = 'PRIMARY KEY')) AS PT ON PT.TABLE_NAME = PK.TABLE_NAME
where fk.table_name = '[table]' -- (Pkeys for table)
You're on your own with indexes and constraints (I'm not fiddling with that in my code generator).
Does that help, or did I miss what you're asking altogether?
|
|
|
|
|
I have a quickbooks database that I need to replicate into sql server.
The quickbooks database I have an ODBC connection to. But inorder to port the data from quickbook to sql server I have to generate the tables in sql server as they are in the quickbooks database. Then I can port the data from quickbooks to sql Server.
SQL Server has no odbc connection to quickbooks otherwise I agree with you.
I have found a piece of code that might help but I currently do not understand it.
http://stackoverflow.com/questions/47239/how-can-i-generate-database-tables-from-c-classes[^]
|
|
|
|
|
I have an application that looks for the next job to process by querying a que table. If it finds a record it does some processing for the corresponding job and then removes that record from the que table. I want to have this application running on more then one server but I'm not sure the best way to keep each instance of the application from trying to process the same record in the que table. Somehow when one instance of the application begins processing a record in the que table it needs to flag that record so that another instance of the application will not process it. What is the best way to do this?
|
|
|
|
|
If you return the info from your table and update the "Processing" flag from within a transaction, the other processes wont overlap due to l ocking caused by the transaction.
|
|
|
|
|
|
I want to know how can I do a random rename to all files in a specefic folder, for example, rename every file name from the current file.jpg to a GUID.jpg then it will be unique and random?
|
|
|
|
|
You've just asked, and answered, a question all in one go. 'grats.
|
|
|
|
|
jrahma wrote: GUID.jpg
yes, GUID is quinque.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Manas Bhardwaj wrote: GUID is quinque.
That many
|
|
|
|
|
Hi,
have a look at Path.GetRandomFileName()
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
hi,
how to convert pdf file format to tiff file format?
I need source code.
regards,
Bill
|
|
|
|
|
billcodes wrote: I need source code.
Do you need it with an all consuming, burning desire? Can you not sleep at night, sweating as you think about all the code that has been lost to you, lost as it cavorts with others, dancing the night away like the brazen harlot that it is? Is it the mistress that drives you wild with desire, while you know that you shouldn't be seduced by the sultry temptress?
You are going to either have to buy (or download open source) components that do this, or you are going to have to write code based on the file formats, both of which are freely available on t'internet.
"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: Can you not sleep at night, sweating as you think about all the code that has been lost to you, lost as it cavorts with others, dancing the night away like the brazen harlot that it is? Is it the mistress that drives you wild with desire, while you know that you shouldn't be seduced by the sultry temptress?
That's me
|
|
|
|
|
Pete O'Hanlon wrote: Do you need it with an all consuming, burning desire? Can you not sleep at night, sweating as you think about all the code that has been lost to you, lost as it cavorts with others, dancing the night away like the brazen harlot that it is? Is it the mistress that drives you wild with desire, while you know that you shouldn't be seduced by the sultry temptress?
You've take up writing trashy novels, haven't you?
You better stop this - you might start turning the newbies on in ways you never thought possible!
|
|
|
|