|
No, a generic class would be something like this*
public class MyList<T> : IEnumerable<br />
{<br />
private List<T> m_InternalList;<br />
<br />
}
As in the example, now you have a Generic class that can support a collection of objects in a type-safe manner and gives the ability to iterate through that collection.
*disclaimer: Not 100% complete and acccurate code, just psuedo code so don't complain;P
-- modified at 18:03 Sunday 27th May, 2007
only two letters away from being an asset
|
|
|
|
|
i want to send 6 datas from microcontrol to Visual c# with serialport.i create byte array variable in c# for saving my serial datas.but when i send datas so synchronization problem becomes.every time i see 255 at the first data why?i get datas and i show them to textboxes.what kind of problem can be?
my code is:
serialport_DataReceived(.........)
{
serialport.read(variable,0,6);
}
could be buffer problem?
|
|
|
|
|
Make sure you're addressing the right serial port.
Device Manager > Your serial port > Properties > Resources > I/O Range (Get the range and maybe translate it to Decimal figures)
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
i have to read data from an excel file and compare it with
data from sqlserver ...how can i read data frmo excel into such a strucutre so that i can compare data...
urgent help needed.........
|
|
|
|
|
I'm using VCS Express 2005.
I have a lot of property definitions in different classes like
public class MyEntity {
public string somestringfield {
get { return (string)Row["somestringfield"]; }
set { Row["somestringfield"] = value; }
}
public string someotherstringfield {
get { return (string)Row["someotherstringfield"]; }
set { Row["someotherstringfield"] = value; }
}
}
When template changes I must manually change it in hundreds of places.
I tried to use template
#define StringFieldTemplate( propname ) \
public string propname { \
get { return (string)Row[propname]; } }
set { Row[propname] = value; } \
};
public class MyEntity {
StringFieldTemplate("somestringfield2")
StringFieldTemplate("someotherstringfield2")
}
But got error.
How to implement this ?
Andrus
|
|
|
|
|
I use DataGridView containing DataGridViewComboBoxColumn column.
Combobox column displays dropdown list opening selection triangle in all rows. This covers part of visible data if columns are narrow.
How to force dropdown list opening control to appear only in active (current) row ?
Andrus.
Andrus
|
|
|
|
|
To reproduce
1. Run the code.
2. Open dropdown list
Observed:
Dropdown list width is same as column width
Expected:
Dropdown list width must be greater than column width
How to make dropdown list width greater than column width in DataGridView ?
Andrus.
using System;
using System.Windows.Forms;
class Form1 : Form {
[STAThread]
static void Main() {
try {
Application.Run(new Form1());
}
catch (Exception e) {
MessageBox.Show(e.ToString());
}
}
private DataGridView dataGridView1 = new DataGridView();
public Form1() {
Controls.Add(this.dataGridView1);
Load += new EventHandler(Form1_Load);
}
private void Form1_Load(object sender, EventArgs e) {
DataGridViewComboBoxColumn
col = new DataGridViewComboBoxColumn();
col.DropDownWidth *= 3;
dataGridView1.Columns.Add(col);
}
}
Andrus
|
|
|
|
|
hi
i want to search by string with pattern, but i want to tell to my regex object that ignore some unicode characters or diacritics (such as "ًٌٍَُِّ") in string, but
how to do ?
|
|
|
|
|
Hi!
You can explicitely specify a character not within a range by using ^ as first character in the character selection, for example [^abcl-p] means "any character except a,b,c and l to p" .
HTH,
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hello all,
i've written some code that displays a ball bouncing around inside a windows
form. In an attempt to eliminate the flickering of the ball i copy-pasted this
into the the Form's constructor:
<br />
this.SetStyle(<br />
ControlStyles.UserPaint |<br />
ControlStyles.AllPaintingInWmPaint |<br />
ControlStyles.DoubleBuffer, true);<br />
Now when I try to run the code I get this error message. Does anyone know why? or know another way to stop this flickering. Thanks
Error msg:
********************************************************************************************
System.ArgumentException: Parameter is not valid.
at System.Drawing.Graphics.GetHdc()
at System.Drawing.BufferedGraphics.RenderInternal(HandleRef refTargetDC, BufferedGraphics buffer)
at System.Drawing.BufferedGraphics.Render()
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsApplication1.Program.Main() in C:\Documents and Settings\Gareth\My Documents\C#\Working_Programs\Bouncing_Ball_With_Gravity\Bouncing_Ball_With_Gravity\Program.cs:line 19
***************************************************************************************************
|
|
|
|
|
hello!
I have 2 problems with a comboBox and a dataGrid.
The first problem is that when i'm selecting a table from the comboBox it's ok, but when i select the second or the third table it's not very good. I have too many lines and columms remaining from the first selected table...i must clear that table or datagrid.
The second problem ... i want that my selected table fit in the dataGrid.
This is my code:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
alege_tabel = comboBox1.SelectedItem.ToString();
dataSet1.Clear();
SqlCommand sel = new SqlCommand();
sqlDataAdapter1.SelectCommand = sel;
sel.Connection = this.sqlConnection1;
if (alege_tabel == "Oferte")
{
dataSet1.Clear();
sqlDataAdapter1.SelectCommand.CommandText = "select * from Oferte";
sqlDataAdapter1.Fill(dataSet1);
dataGrid1.SetDataBinding(dataSet1, dataSet1.Tables[0].TableName);
}
if (alege_tabel == "Locatie")
{
dataSet1.Clear();
sqlDataAdapter1.SelectCommand.CommandText = "select * from Locatie";
sqlDataAdapter1.Fill(dataSet1);
dataGrid1.SetDataBinding(dataSet1, dataSet1.Tables[0].TableName);
}
if (alege_tabel == "Transport")
{
dataSet1.Clear();
sqlDataAdapter1.SelectCommand.CommandText = "select * from Transport";
sqlDataAdapter1.Fill(dataSet1);
dataGrid1.SetDataBinding(dataSet1, dataSet1.Tables[0].TableName);
}
if (alege_tabel == "Rezervari")
{
dataSet1.Clear();
sqlDataAdapter1.SelectCommand.CommandText = "select * from Rezervari";
sqlDataAdapter1.Fill(dataSet1);
dataGrid1.SetDataBinding(dataSet1, dataSet1.Tables[0].TableName);
}
}
|
|
|
|
|
i wrote this code in Class Librery
DirectoryInfo GetPath = new DirectoryInfo("MD.DAT");
string Path = GetPath.FullName;
this code back the path of the MD.DAT file
but if i use a openfiledialog befor i call this code
it back the path of the openfiledialog
how can i soleve this problem
MD_NADA
|
|
|
|
|
Without seeing your code it is difficult to help you out, but I am guessing that you are setting your Path variable when the openfiledialog returns.
Note you can also use FileInfo to get the path of a file.
Ben
|
|
|
|
|
Hi,
when you specify a relative file (a partial name) the "current directory" gets involved.
This CD may get changed in many ways, e.g. by showing an OpenFileDialog,
SaveFileDialog, ...
It depends on their RestoreDirectory property (which modified the behavior the
second time you show such a dialog).
|
|
|
|
|
hi
in my windows based application i need to export data from grid to excel,word. iam very new to c#.net.please kindly help me.
|
|
|
|
|
hi,
you can use Excel API for that purpose.
Just include Microsoft Excel component in your project's reference and you will be able to use Application.Excel component.
Manoj
Never Gives up
|
|
|
|
|
Hy,
I have a problem with an Open File Dialog. When I press the browse button I open an Open File Dialog.I try to make a folder...an I can make it.And If I try to delete it my program crashing with message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
Can someone to help me with some idea?
Can I put a restriction to only selection without changes in my Open File Dialog?
10x
|
|
|
|
|
I added elements to hashtable but they are not in the order in which i added. The code is below:
Hashtable table = new Hashtable(4);
table[new Regex(@"^(-?)(\d*?)\.?(\d{0,1})?$")] = "$1$2.$3";
table[new Regex(@"^(\d*?)\.?(\d{0,1})?(-?)$")] = "$3$1.$2";
table[new Regex(@"^(-?)(\d{1,3}?)((?:,\d{3})*)\.?(\d{0,1})?$")] = "$1$2$3.$4";
table[new Regex(@"^(\d{1,3}?)((?:,\d{3})*)\.?(\d{0,1})?(-?)$")] = "$4$1$2.$3";
I want these elements in the same order. Some times it takes the same order and some times it does not. I know hashtable does not take elements in same order.
But is there a way for this?
|
|
|
|
|
Yes, this is an effect of hash tables.
"Realize that the order with which the items are inserted and the order of the keys in the Keys collection are not necessarily the same. The ordering of the Keys collection is based on the slot the key's item was stored."
ref from: http://msdn2.microsoft.com/en-us/library/aa289149(VS.71).aspx[^]
If you don't like this behavior then don't use a hash table.
|
|
|
|
|
|
You could also try SortedList. It's not as efficient as Hashtable but may not matter for you if you only have a few entries.
Kevin
|
|
|
|
|
I am using a picture box to display a number of points on the screen. My problem is that I dont know how to resize the picture so I can see the points on all the picture box and not only in one part of the picture box.
|
|
|
|
|
Hello there! I've been trying, without any luck for the past week or so to get the "currently playing" movie/song in my Windows Media Player.
I know I need to use SendMessage to send and receive info from WMP. I've managed to write Play/Pause/Stop methods:
Example:
---
// stop WMP movie/song
IntPtr ptrWindow = FindWindow("WMPlayerApp", "Windows Media Player");
if (ptrWindow == IntPtr.Zero)
return;
SendMessage(ptrWindow, WM_COMMAND, 0x00004979, 0x00000000);
---
However, this doesn't get me anywhere near the "Currently Playing" movie/song. I've looked into the WMP SDK, but that doesn't seem to help. I don't want to make a new instance of WMP. I want to read the currently playing info from my own WMP app that's open.
I'd appreciate any help in getting closer to what I need.
Thanks in advance.
|
|
|
|
|
The playing item could be found in:
WMP.currentMedia.name
Heino
|
|
|
|
|
Thank u for your reply!!
how can i appoint this Object?
please give me an example?
|
|
|
|