|
But multiple constraints mean the type T must implement all of those.
There is no way to say "int OR float" (which would have to automatically generate an interface with all methods common between int and float).
But unfortunately, .NET doesn't support 'dynamic interfaces' (you declare an interface, and all classes having the appropriate methods will automatically implement it). Actually, I think VB10 will have something dynamic interfaces, but I guess it'll be implemented on top of Reflection/the DLR.
|
|
|
|
|
Thanks.
Syntax proposal: public class MyClass<T> where T in { int, long, float, double }
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Right, that would be good. Or the numeric types should implement some sort of IDoMath interface and we could use that.
I also want an enum constriant.
|
|
|
|
|
If they made it so we had a Numeric constraint, or they implemented some common interface (INumeric), that would fix it for all the integral data types and enums too in one go.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I want enums separate from the other types. I have generic classes that should accept enums only. As it stands, I have to check at runtime and throw and Exception.
|
|
|
|
|
Hi,
I'm using the control SplitContainer on run time.
uppon request I'm generating a tab that contains SplitContainers.
I set all the properties as needed including the SplitterDistance,
BUT when the application is running the spliter is not positioned as expected.
it seems that it use some default parameter that ovveride the explicit setting.
Thanks for your help,
lune
|
|
|
|
|
Its hard to comment about it but a wild guess could be to check your dock and anchor properties.
|
|
|
|
|
The dock is fill.
and anchor is top and left.
I saw that if I set the parameter in an event such SelectedIndexChange it works.
but I feel that is wrong to do such a thing (and also it doesn't cover all the cases)
any other guess?
Thanks.
|
|
|
|
|
this comment made me think that may be its some code level change overriding the design view changes. Go through your code and make sure that your adjusted styles not being overridden at code level.
|
|
|
|
|
datagrid is having 4 values.
presently selection is on 4'th record and it is moving to 2'nd record...
how to get previously selected column index(i.e 4'th record) index.
can anyone help me
|
|
|
|
|
i got the code...
thank you...
if (gvcomments.Rows[pre_Index].Cells[CommonConstants.Created].Style.ForeColor == Color.Red)
{
gvcomments.Rows[pre_Index].DefaultCellStyle.Font = new Font(gvcomments.SelectedRows[0].InheritedStyle.Font, FontStyle.Bold);
}
else
{
gvcomments.Rows[pre_Index].DefaultCellStyle.Font = new Font(gvcomments.SelectedRows[0].InheritedStyle.Font, FontStyle.Regular);
}
|
|
|
|
|
handle related index change event and always keep track of previous index in some location. In this way you will always have a valid old index saved and before updating it to newer index you can make use of it.
|
|
|
|
|
Hi,
I'm writing TCP application to communicate with a server machine. There is an interesting thing called TCP Window Scaling, how can i achieve through C#?
|
|
|
|
|
satsumatable wrote: I'm writing TCP application to communicate with a server machine. There is an interesting thing called TCP Window Scaling, how can i achieve through C#?
Based on the Wikipedia definition of TCP Window Scale Option[^], it seems you don't achieve it at the application level.
|
|
|
|
|
Hello All;
i make a user control on c# using ultragrid control the problem is when i take the dll in order to use it in other projects the data doesnt appear, the grid reads the data from the data base
the code of the user control:
the grid name here is ulGrid
public partial class GridUserControl : UserControl<br />
{<br />
Infragistics.Win.UltraWinGrid.UltraGrid ulGrid = new UltraGrid();<br />
Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter ulExcel = new UltraGridExcelExporter();<br />
Infragistics.Win.UltraWinGrid.UltraGridPrintDocument ulPrint = new Infragistics.Win.UltraWinGrid.UltraGridPrintDocument();<br />
<br />
<br />
bool GridRightLeft;<br />
string HeaderTitle;<br />
string HeaderRightDetails;<br />
string HeaderLeftDetails;<br />
<br />
public GridUserControl()<br />
{<br />
InitializeComponent();<br />
ulItasGrid.ContextMenuStrip = contextMenuStrip1;<br />
}<br />
<br />
public delegate void GridEventKeyDown(object sender,KeyEventArgs e);<br />
public delegate void GridEventKeyUp(object sender, KeyEventArgs e);<br />
public delegate void GridEventMouseDown(object sender, KeyEventArgs e);<br />
public delegate void GridEventMouseClick(object sender, KeyEventArgs e);<br />
<br />
<br />
<br />
<br />
public bool GridRightToLeft<br />
{<br />
set<br />
{<br />
GridRightLeft = value;<br />
}<br />
get<br />
{<br />
return GridRightLeft;<br />
}<br />
}<br />
<br />
<br />
public string LeftDetails<br />
{ <br />
set<br />
{<br />
HeaderLeftDetails = value;<br />
}<br />
get<br />
{<br />
return HeaderLeftDetails;<br />
}<br />
}<br />
public string RightDetails<br />
{<br />
set<br />
{<br />
HeaderRightDetails = value;<br />
}<br />
get<br />
{<br />
return HeaderRightDetails;<br />
}<br />
}<br />
DataTable dt = new DataTable();<br />
public DataTable DataTableSource<br />
{ set<br />
{<br />
ulGrid.DataSource = dt;<br />
}<br />
<br />
<br />
get<br />
{<br />
return dt;<br />
}<br />
<br />
}<br />
<br />
<br />
public object DataSource<br />
{<br />
get<br />
{<br />
return ulGrid.DataSource;<br />
}<br />
set<br />
{<br />
ulGrid.DataSource = value;<br />
<br />
try<br />
{<br />
ulGrid.DataBind();<br />
}<br />
catch (Exception ex)<br />
{<br />
throw new Exception(String.Format("Could not bind data to grid"));<br />
}<br />
}<br />
}<br />
<br />
public string DataMember<br />
{<br />
set { ulGrid.DataMember = value; }<br />
get { return ulGrid.DataMember; }<br />
<br />
}<br />
<br />
<br />
<br />
public string HeaderReport<br />
{<br />
set<br />
{<br />
HeaderTitle = value;<br />
}<br />
get<br />
{<br />
return HeaderTitle;<br />
}<br />
}<br />
<br />
public AutoFitStyle AutoFit<br />
{<br />
set<br />
{<br />
this.ulItasGrid.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns;<br />
}<br />
get<br />
{<br />
return this.ulItasGrid.DisplayLayout.AutoFitStyle;<br />
}<br />
}<br />
<br />
public Color Appearance<br />
{<br />
set<br />
{ <br />
this.ulItasGrid.DisplayLayout.Appearance.BackColor = Color.White;<br />
}<br />
get { <br />
return this.ulItasGrid.DisplayLayout.Appearance.BackColor;<br />
}<br />
}
and the code of the connection class for testing the grid:
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Data.SqlClient;<br />
using System.Configuration;<br />
using System.Data;<br />
<br />
<br />
namespace testthegrid<br />
{<br />
class Connection<br />
{<br />
SqlConnection ConnectionStr = new SqlConnection();<br />
<br />
public Connection()<br />
{<br />
ConnectionStr.ConnectionString = "Data Source=.; Initial Catalog=GridExample;Integrated Security=SSPI";<br />
}<br />
<br />
public SqlConnection conn<br />
{<br />
get<br />
{<br />
return this.ConnectionStr;<br />
}<br />
set<br />
{<br />
this.ConnectionStr = value;<br />
}<br />
}<br />
<br />
<br />
public void OpenConnection()<br />
{<br />
if (ConnectionStr.State != ConnectionState.Open)<br />
ConnectionStr.Open();<br />
}<br />
<br />
<br />
public void CloseConnection()<br />
{<br />
try<br />
{<br />
if (ConnectionStr.State != ConnectionState.Closed)<br />
ConnectionStr.Close();<br />
}<br />
catch { }<br />
}<br />
}<br />
}
and the code for testing the grid is:
<br />
namespace testthegrid<br />
{<br />
public partial class Form1 : Form<br />
{<br />
private Connection connection = new Connection();<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
FillGrid();<br />
}<br />
private void FillGrid()<br />
{<br />
connection.OpenConnection();<br />
DataTable dt = new DataTable();<br />
SqlDataAdapter da = new SqlDataAdapter("select * from AccountInfoA", connection.conn);<br />
da.Fill(dt);<br />
gridUserControl1.DataTableSource = dt;<br />
connection.CloseConnection();<br />
<br />
}
there is no data appears in the grid
thanx a lot
|
|
|
|
|
Try setting up the binding BEFORE you read the data.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
thanx, but it doesnt solve the problem!!
|
|
|
|
|
Hello all,
I would like to save current word file to My Documents when user clicks on Button which is Placed in Ribbon ????
Can anybody guide me how to do it ???
|
|
|
|
|
I would like to save current word file to My Documents.
means?
Why you are using savedialogbox when you have to save it in MyDocuments only
Cheers!!
Brij
|
|
|
|
|
i would like to save the word file on onclick event of my Button which is in Ribbon .....i don't want to use office inbuilt saving option.....
|
|
|
|
|
Ummm .... SaveFileDialog and System.IO.File.AppendAllText.
I'm pretty sure your going to have to double check the names
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Hi all,
I've created a windows application through C# to add appointment in outlook 07 programatically. now i want to perform some action as soon as a new contact is added in the outlook i.e. i want to handling add contact event. please help me.
|
|
|
|
|
Check this event
Outlook.Inspectors OutlookInspectors
|
|
|
|
|
thnx. i've created an addin and successfully captured add/modify event for appointment. now for normal appointment modifcation as well as for drag n drop same event modify is gets fired. now i want to diferentiate between normal modificATION and modification through drag n drop.
|
|
|
|
|
Hi,
I have a panel on a windows form.
In the panel, I have a label, I have set the visible property of the label as False in design time.
now at runtime, in a function I am trying to make label visible like this,
label1.visible = true;
but the label1.visible property does not change, it still has false value, but once the form executes completely, label becomes visible, I cannot understand, How this is happening.
can someone tell me that why the label1.visible property does not become true, when I explicitly assign true to it.
Thanks in advance,
Regards
Mahesh
|
|
|
|