|
Hi all, I am trying to pass a function name as a parameter and use it to create an OracleDataReader:
<br />
private void DataHandler(string type, string function)<br />
{<br />
AuthViewsLookup myLookup = new AuthViewsLookup(m_AppParam);<br />
<br />
OracleDataReader rdr = myLookup.function;<br />
<br />
while(rdr.Read())<br />
{<br />
}<br />
<br />
rdr.Close();<br />
}<br />
setting the reader to myLookup.function does not work, b/c it wants the actual function name. How can I make this work? Thanks for any help.
|
|
|
|
|
|
That's not exactly what I meant. I want to tell it what function to go to by passing in the function's name.
|
|
|
|
|
I’m a fairly new programmer (was taught C++ over a two year program NAIT) and very new to C# and I was hoping someone can explain to me why string doesn’t have a constructor that accepts a string? To me the following line of code seems intuitively correct but it doesn’t work.
string s = new string(“dog”);
or
string s = new string();
s=”dog”
There must be a reason that the above doesn’t work (other than making me angry.)
The closest I can come to doing the above is
string s = “dog”;
or
string s = “\0”;
And that works but I’d like s to be DMAed.
Admittedly, my understanding of DMA with managed code is week at best. That may be the problem. Any explanations will be helpful.
Thank you,
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
12029 45 Street N.W.
Edmonton, Alberta, Canada T5W 2T7
Res. Ph: (780) 695.5589
Email: rhahn82@telus.net
|
|
|
|
|
I'm not entirely sure why this really matters to you, however if you look through the documentation you will see there are a series of different parameters that the String class can take as a parameter for its constructor. You could do the following (if you wanted that is):
string s = new string("Hello".ToCharArray());
The string class is a reference type, so remember it's important to check for a null value, but otherwise just use the assignment operator, which is how the majority of people tend to use it.
string s = "Hello";
- Nick Parker My Blog | My Articles
|
|
|
|
|
So because it’s a reference type trying to put it on the heap is redundant? Why doesn’t anyone do this:
string s = new string("Hello".ToCharArray());
?
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
HahnTech wrote:
So because it’s a reference type trying to put it on the heap is redundant?
No, your missing the point, I am just not sure I understand why you are hung up on the design of the class? Like I said, what I showed you is simply something you could do, however unlikely.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I am so frustrating to make list in propertygrid by using arraylist. I am well-aware about other articles about this, but I cant get it working. Do I have to use PropertyDescriptorCollection or ICollection? I am not sure bec I dont know which is best to use for building list in propertygrid by arraylist.
I want nodes to look like this:
For example:
-Category
-List 1
Color
Length
....
+List 2
Color
Length
....
+List 3
....
|
|
|
|
|
If you want your collection of properties "rolled-out" (i.e., no "..." button) in the PropertyGrid then your object will need to implement ICustomTypeDescriptor and override the two GetProperties methods. For everything else, just return TypeDescriptor.AppropriateMethod with noCustomTypeDesc parameter set to true (so that it doesn't recursively call your ICustomTypeDescriptor method).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I am little confusing about override the two GetProperties methods. Can you give me more specifics about that? I was curious about TypeDescriptor.AppropriateMethod method so I looked at MSDN library and it was not there. How did you find its method?
|
|
|
|
|
Notice how AppropriateMethod was italicized/emphasized? That means it's not actually what you look up. It would've been logical for you to lookup the TypeDescriptor class even if I did mispell a method or property name and look at it's class documentation. For example, look up TypeDescriptor in the .NET Framework SDK documentation and you'll see the GetProperties overloaded methods.
When you implement the ICustomTypeDescriptor you simply define the two overloaded GetProperties methods as you would with any other interface members. If you're confused about how to implement interfaces, then I suggest you first read the C# Language Specification[^], specifically about Interfaces[^].
For example:
public class MyClass : ICustomTypeDescriptor
{
public TypeConverter GetConverter()
{
return TypeDescriptor.GetConverter(this, true);
}
public PropertyDescriptorCollection GetProperties()
{
return GetProperties(null);
}
public PropertyDescriptorCollection GetProperties(Attribute[] filter)
{
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for telling about this:read the C# Language Specification[^], specifically about Interfaces[^]. and it helped me alot but it didnt help me with my current problem. I did what I still trying to get any results from PropertyDescriptorCollection in propertygrid, but all I got is blank. I followed your suggestions and I got it all in collection from arrays.
public class CMainForm : System.Windows.Forms.Form
{
public void ShowPropertyGrid()//init. propertygrid with datas and objects
{
ArrayList arrayList = .....///stored the arraylist from other class
foreach(ILogical pILogical in arrayList
{
string[] strHeaderArray = null;
((IEVHeaderItem)pILogical).GetHeaderDetails(out strHeaderArray);
SubListInfo.Lists.List = "List" + nCount;);///List1, List2, List3,....
SubListInfo.Lists.Type = pILogical.Type;
for(int i=0; i < strHeaderArray.Length; i++)
{
string strValue;
((IEVHeaderItem)pILogical).GetDetailColumn(i, out strValue);
if(i == 3)
ListInfo.Lists.Color = strValue;
........
}
}
}
}
[TypeConverter(typeof(SurfaceConverter))]
public class SubListInfo : SubListData
{
private int m_nID = 0;
private string m_strColor = "";
.......
public SubListInfo()
{
}
[ReadOnly(true)]
public string Color
{
get { return m_strColor; }
set { m_strColor = value; }
}
..........
}
public class SubListData
{
private string m_strList = "";
......
public SubListData() {}
[Browsable(false)]
public string List
{
get { return m_strList; }
set { m_strList = value; }
}
....
}
public class CListInfo : ICustomTypeDescriptor
{
private ArrayList m_arrayList;
#region ICUSTOMTYPEDESCRIPTOR
public String GetClassName()
{
return TypeDescriptor.GetClassName(this,true);
}
... I followed those rest of them like you said from previous message.
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public PropertyDescriptorCollection GetProperties()
{ return GetProperties(null); }
[TypeConverter(typeof(ListConverter))]
public PropertyDescriptorCollection GetProperties()
{
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
for(int i = 0; i < m_data.Count; i++)
{
SurfaceCollectionDesc pd = new SurfaceCollectionDesc(m_data,i);
pds.Add(pd);
}
return pds;
}
#endregion
}
internal class ListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType )
{
if( destType == typeof(string) && value is SurfaceInfo )
{
ListInfo emp = (ListInfo)value;
return emp.List;///List1, List2, List3,....
}
return base.ConvertTo(context,culture,value,destType);
}
}
I tried to used those codes(below) if its collection(there is three lists for now) is working or not. so it showed only last List(List3) and it didnt displayed first two lists.
[TypeConverter(typeof(ListConverter))]//,CategoryAttribute("Lists")]
public SubListInfo Lists
{
get
{
return subLists;
}
}//////it showed only last List(List3)
Did I miss something important about PropertyDescriptorCollection or TypeConverter
that displays whole lists? I may overlooking something that I alway do that.
|
|
|
|
|
Hello,
I want to use SinatureCapturing (Saving the Signature in Sql Server Ce Database and Retrieving the Signature from Sql Server Ce Databse). from the MSDN Example: http://msdn.microsoft.com/mobility/understanding/articles/default.aspx?pull=/library/en-us/dnnetcomp/html/PPCSignatureApp.asp
I looked at this example and after one while I came to the realization that I have to use the SignatureControl.cs File and the Network.cs File.(I added this files to my application). Then I add the following code to my Main Form (I know that the database saving requires additional code, but I want only test at the beginning if the Control is displayed and if I am able to write on this Control with the pen.):
SignatureControl _signature = new SignatureControl();
and in the constructor:
_signature.Location = areaSignature.Location; //areSignature is the name of the panel
_signature.Size = areaSignature.Size;
this.tabPage2.Controls.Add(this.areaSignature);
I only added this code to the MainForm according to the constructor and FormLoad Method of the MainForm of the sample application. (I also set the sign here file to embedded resource of my application.)
But when I deploy the application the panel is displayed without any additional functionality or the bachground sign here.
Anybody an idea what I have forgotten?
robert
|
|
|
|
|
|
I want to know how to use DataGridColumnStyle to set the width of my datagrid. I know how to use PreferredColumnWidth to set the width of the oveall colunm, but it is not what I want. I want to set individual column.
Here is my program
I also want to know if there is a good documentation for the .net classes. While I was working in the DataGridClass. My class is defined as dataGrid1, from dataGrid1, there is not way to know that DataGridColumnStyle exists. I want to know is there is a good book or documentation tha point out intaction between associated classes like for instance DataGrid and DataGridColumnStyle.
<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
double[] dData1 = new double[100];<br />
double[] dData2 = new double[100];<br />
<br />
DataTable dt = new DataTable();<br />
DataRow dr;<br />
<br />
dt.Columns.Add(new DataColumn("Index", typeof(int)));<br />
dt.Columns.Add(new DataColumn("Sinve Values", typeof(float)));<br />
dt.Columns.Add(new DataColumn("Cosine Values", typeof(float)));<br />
<br />
dataGrid1.PreferredColumnWidth = 100;
<br />
for(int i=0;i<100;i++)<br />
{<br />
dData1[i] = Math.Sin(0.1*i);<br />
dData2[i] = Math.Cos(0.2*i);<br />
dr = dt.NewRow();<br />
dt.Rows.Add(dr);<br />
dr[0] = i;;<br />
dr[1] = dData1[i];<br />
dr[2] = dData2[i]; <br />
} <br />
dataGrid1.DataSource = new DataView(dt); <br />
waveformPlot1.PlotY(dData1);<br />
waveformPlot2.PlotY(dData2);<br />
}<br />
|
|
|
|
|
If you want to know if there's good documentation, then read it and determine whether you think it's good.
You can set the width of a specific column using a DataGridColumnStyle that you add to a DataGridTableStyle for a specific DataTable (or type, if reflecting against something other than a DataSet or DataTable ), which you add to DataGrid.TableStyles .
You should read the documentation, which also presents articles. The DataGridColumnStyle does exactly what you're asking and is specific to the column it represents in a DataGrid .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
After adding all these extra codes, it still doesn't work. It shouldn't take all too much effort jsut to increse or decrease the length of a column in a grid.
In terms of the documentation, I think it would have been bette to show interaction from one class to another.
<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
double[] dData1 = new double[100];<br />
double[] dData2 = new double[100];<br />
<br />
DataTable dt = new DataTable();<br />
DataRow dr;<br />
DataGridTableStyle ts1 = new DataGridTableStyle();<br />
DataGridColumnStyle boolCol = new DataGridBoolColumn();<br />
<br />
dt.Columns.Add(new DataColumn("Index", typeof(int)));<br />
dt.Columns.Add(new DataColumn("Sinve Values", typeof(float)));<br />
dt.Columns.Add(new DataColumn("Cosine Values", typeof(float)));<br />
<br />
ts1.MappingName = "Index";<br />
boolCol.MappingName = "Index";<br />
boolCol.Width = 20;<br />
ts1.GridColumnStyles.Add(boolCol); <br />
dataGrid1.TableStyles.Add(ts1);<br />
<br />
for(int i=0;i<100;i++)<br />
{<br />
dData1[i] = Math.Sin(0.1*i);<br />
dData2[i] = Math.Cos(0.2*i);<br />
dr = dt.NewRow();<br />
dt.Rows.Add(dr);<br />
dr[0] = i;;<br />
dr[1] = dData1[i];<br />
dr[2] = dData2[i]; <br />
} <br />
dataGrid1.DataSource = new DataView(dt); <br />
waveformPlot1.PlotY(dData1);<br />
waveformPlot2.PlotY(dData2);<br />
}<br />
|
|
|
|
|
It's not difficult, but your problem is that you need to name your DataTable . The DataGrid associates a particular DataGridTableStyle with a DataGrid by matching the DataTable.TableName (you can pass this to the constructor) with one of the DataGridTableStyle 's MappingName that was added to the DataGrid.TableStyles property. Your modified code below works fine:
double[] dData1 = new double[100];
double[] dData2 = new double[100];
DataTable dt = new DataTable("Test");
DataRow dr;
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = dt.TableName;
DataGridColumnStyle boolCol = new DataGridBoolColumn();
dt.Columns.Add("Index", typeof(int));
dt.Columns.Add("Sinve Values", typeof(float));
dt.Columns.Add("Cosine Values", typeof(float));
boolCol.MappingName = "Index";
boolCol.Width = 20;
ts1.GridColumnStyles.Add(boolCol);
dataGrid1.TableStyles.Add(ts1);
for (int i=0; i<100; i++)
{
dData1[i] = Math.Sin(0.1*i);
dData2[i] = Math.Cos(0.2*i);
dr = dt.NewRow();
dt.Rows.Add(dr);
dr[0] = i;
dr[1] = dData1[i];
dr[2] = dData2[i];
}
dataGrid1.DataSource = dt; You did, however, forget to add column styles for your other columns. When you use table styles with defined columns (even just 1), no columns are auto-generated.
Besides, using a DataTable here is unnecessary. A simple array of some struct like so would work:
public struct Data
{
public int Index;
public double Sinve;
public double Cosine;
} In this case, you set DataGridTableStyle.MappingName to "Data". This is documented in the DataGridTableStyle.MappingName property documentation.
Also, why are you binding a DataGridBooleanColumn to an int DataColumn ? That's going to set it to either 0 or 1 and will start (for all but the first row) in an indeterminate state.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I am trying to create a generalized control that functions similarly to the ASP Image Button control but with the added feature of being able to programmatically superimpose text over the image.
There are many times when a GUI developer would like to create an image and programmatically place specific text on that image. For example: A restaurant application that graphically shows a restaurant table layout as an icon (see below). It would be nice to be able to write text over the table icon that is meaningful to the user of the application rather than place text outside the image area. When the user clicks on the table, an event handler would process whatever the application requires.
Table ID = A7
Guest Count = 3 people
Server ID = 22
It would be far better from a GUI view point to create a larger Image and place the actual text directly in the image:
Likely this Server control needs to look exactly like the ImageButton with an added attribute perhaps called ImageTextLine with properties:
ImageTextLine.Text
ImageTextLine.Alignment (Top, Center, Left, Right)
A single text line could suffice with string concatenation handling the actual display.
This must be a generalized sever control that will take any image and allow text to be placed over the top of the image in various alignment positions.
The closest I can come to finding anything remotely resembling the above scenario is creating a text-image which uses GDI+ to create a rectangle or circle (ellipse) as a drawing shape. I don’t want a rectangle or circle, I want an image of my choosing.
|
|
|
|
|
So what's your question?
If you want to know how to do this, there's many articles here on CodeProject and other sites about drawing images in ASP.NET (BTW, next time post ASP.NET-related questions in the ASP.NET forum) either to the response stream or to a persistent file (can be dangerous).
Specifically, read the documentation for the Graphics.MeasureString and Graphics.DrawString methods, which also provide examples.
You could even load-up a template image using either the Bitmap constructor or either Image.FromFile or Image.FromStream , call Graphics.FromImage , and draw your text (always remember to call Graphics.Dispose when finished).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I have been writing a C# app with a three tier (Database, business and user level) approach. I would like to do some testing across a network but have no idea on how to expose the business layer on the sever machine so other computers can then use this component across the network.
Can anyone point to an article that will direct me on how to do this?
The machines are XP/2000 machines.
Thanks in advance.
Stephen
|
|
|
|
|
Why do you want to expose it over the network, unless you intend to do that anyhow ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
What do you want to test of the business layer? The interaction interfacing with the user level or the database level?
How do you currently get these two levels to interact with each other?
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
On the server I want to run both the data and business tier and run only the user interface on each work station.
I need to test this to make sure that this will work fine first before installing the app and so i would like to test it on my home network.
Can anyone help?
Thanks
|
|
|
|
|
You can't do this automatically.
If remote access was your requirement, you should be using .NET remoting. However this was a thing to consider in the design phase. Now that you already done some amount of coding, I am afraid you have to re-code to incorporate .NET remoting in your code.
Refer MSDN and Code Project regarding tutorials on this topic.
Salil Khedkar [^]
|
|
|
|