|
yeah the problem is since its tied to a class I cant get a tablestyles object
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
okay i want to bind a xml document to a listbox, i have this code:
string fn="TaxiQ.xml";<br />
DataSet ds=new DataSet();<br />
ds.ReadXml(fn);<br />
foreach (DataTable dt in ds.Tables)<br />
{<br />
<br />
<br />
lBox1_t.Items.Add(dt.TableName);<br />
}<br />
<br />
dataSet=ds;<br />
lBox1_t.SelectedIndex=0;<br />
fnSchema=fn;
but i need the information in each individual element of TaxiQ.xml it only gives me the table names , how would i get the contents of the elements
This is my xml doc:
?xml version="1.0" standalone="yes"?>
TaxiQ>
Taxi>
UserId>asfSFAas
Date>fdsafasdfdsa
/Taxi>
Taxi>
UserId>fds
Date>7/30/2003 3:18:59 PM
/Taxi>
/TaxiQ>
Thanks for the help!!
Da Intern
|
|
|
|
|
I haven't tested it but I believe this is what you need
<br />
foreach( DataRow row in ds.Tables[0].Rows )<br />
{<br />
lBox1_t.Items.Add(row["UserId"]);<br />
}<br />
|
|
|
|
|
it worked perfectly thanks alot
Da Intern
|
|
|
|
|
save your self the trouble and use ReadXMl method of the dataTable
I'm not an expert but I play one on TV
|
|
|
|
|
listBox1.DataSource = table;
listBox1.DisplayMember = "Column Name";
|
|
|
|
|
I'm sure this is done, but I can't for the life of me find out how.
For instance, how do you iterate through the collection of controls on a form and get the Object name of that control?
If I could do this, I would be all set.
Any ideas would be greatly appreciated!
Tim
|
|
|
|
|
<br />
private void button6_Click(object sender, System.EventArgs e)<br />
{<br />
for(int x=0;x!=this.Controls.Count;x++)<br />
{<br />
MessageBox.Show(this.Controls[x].Name);<br />
}<br />
}
try that.
|
|
|
|
|
Thanks C Sharp
. . . it would normally work too.
In fact, I was using
foreach (Control cname in this.Controls )
{
this.textBox2.Text += cname.Name;
}
But it turns out that the "Name" property is not supported by the .NET Compact Framework.
Good grief!
I'll never be able to scan through my controls and treat a particular control.
Anyone know why?
Do I need to subclass them to add the Name property?
If so, how would I do this?
(sorry, a definate newbie here)
|
|
|
|
|
Why not implement the Serialize class so you can persist it to a file?
|
|
|
|
|
How you would do this in the Compact Framework?
|
|
|
|
|
Sorry I dont know about the compact framework
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
First a "disclaimer": I am a hobby programmer, so the following question might be silly...
I have a problem with implementing the factory pattern. It is the following line that raises a "System.InvalidCastException: Specified cast is not valid.":
IProvider p = (IProvider)Activator.CreateInstance(pd.Assembly, pd.Class);
Somewhere else I read something about interfaces and versions and that they need to be in sync. Might this have something to do with my problem? How would I solve it?
Cheers,
Marcel
|
|
|
|
|
simply put the pd class is not in the chain of IProvider classes. It doesnt inherit it nor does it implement it
|
|
|
|
|
Nidi wrote:
Somewhere else I read something about interfaces and versions and that they need to be in sync
Not only do the versions to be in sync but the IProvider used by the class must reside in the same assembly as the one already loaded by your code.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
After thinking about my response for a bit I want to clarify this.
In C and C++ you don't have true type safety, say you write a DLL that provides a block of memory described as such:
struct DATA {
int data1;
int data2;
char data3;
}; Now I can take your DLL and so long as I have defined a similar looking struct I can access the data within that block of memory easily.
You can't do the same thing in .NET, in .NET to access that same block of memory you have to use the same structure that was defined in the DLL (.NET calls the DLL an assembly).
In most cases this isn't a problem, but you do run into problems if you attempt to do what you could do in C -- f.e. if you define a struct or class for use in your DLL then redefine that struct or class within your application you will not be able to cast between the two freely. The
Hope that makes more sense,
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
Hi
I need to bind (or dock) a window to the right side of the screen. Also, no other window (from my or another application) show be able to go over it, maximized or not.
How can i do this ?
Thanks
Heelios
|
|
|
|
|
You can just set the location and size of your window based on the current screen dimensions and specify it as a topmost window.
To make sure maximized windows don't extend under it you can use the Windows API to specify the work area of any monitor. The work area specifies the "portion of the screen not obscured by the system taskbar or by application desktop toolbars."
On the primary monitor you will need to make a call to SystemParametersInfo passing SPI_SETWORKAREA and a new rectangle that leaves room for the taskbar and wherever you want to put your window. For a monitor other than the primary one take a look at GetMonitorInfo ...
|
|
|
|
|
I'm trying to do a quick search on a string array. I'm using IndexOf() but I'm not getting the desired results. I've tried two ways, the first I thought should work, the second is just to prove to you I don't know what I'm doing.
<br />
private int CheckIsDate(string ColumnName)<br />
{<br />
string strDate = "Date";<br />
int position = strDate.IndexOf(ColumnName);<br />
return position;<br />
<br />
}<br />
<br />
private int CheckIsCurrency(string ColumnName)<br />
{<br />
string[] strCurrency = {"Amount","Cost"};<br />
int position = -1;<br />
foreach (string s in strCurrency)<br />
{<br />
if (s.IndexOf(ColumnName) == -1)<br />
{<br />
<br />
}<br />
else<br />
{<br />
position = 0;<br />
break;<br />
}<br />
}<br />
<br />
return position;<br />
<br />
}<br />
This should be simple right?
Robert
|
|
|
|
|
|
leppie wrote:
and paste less code
Oops, was asuming more was better.
I just want to know if my string exists in the array. In the debugger I can see that it does exist.
For example. I have a column named Amount billed. The strings in my array are {"Amount","Cost"}. I am using IndexOf to search the ColumnName for one of the strings in the array.
It doesn't find "Amount" for some reason.
Thanks
Robert
|
|
|
|
|
It should work. maybe it something else your doing
int iCOunt = -1;
foreach ( string s in strCurrency )
{
iCount++;
if ( s.IndexOf(ColumnName) != -1 )
return iCount;
}
|
|
|
|
|
No, I had it backwards. I was looking to see if s existed in ColumnName. so I needed to put ColumnName.IndexOf(s) instead of s.IndexOf(ColumnName).
Such is life.
Robert
|
|
|
|
|
I think what you're asking is to see if a particular string is in an array of strings. Use this:
public bool ExistsInArray(string s, string[] sList)
{
foreach (string item in sList)
{
if (item == s) return true;
}
return false;
}
In other words, check all strings in the list to see if the one I want is there. If it is, exit immediately I find it, returning true. If I fall through the loop, having checked all strings in the list, return false.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
but if you do "==" arent you just comparing the instances and not the value
s.Equals(ColumnName)
|
|
|
|