|
Hi
I don't think it is possible.Because RowState property of DataRow is a read only property.out side code can't change its value.
Public ReadOnly Property RowState() As System.Data.DataRowState
Member of: System.Data.DataRow
Just go and look at all members of DataRow using object browser.
(Use Alt+Ctrl+J shortcut in .NET IDE)
M.Sendilkumar
Chennai.
|
|
|
|
|
hi,
You wrote :
I want to change a RowState property of a DataRow from a DataTable manually.
RowState property is used to get the current state of row. And it is a read-only property. You can access but you can't set the value.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I'm new with programming winform. I want to know how to draw a new control or extend a control. Please help me. Thanks in advanced.
kunkun
|
|
|
|
|
Hi,
you can create new controls by
Inherit from an existing control or
Inherit from UserControl or
Inherit from Control.
Thanks,
SGS
|
|
|
|
|
Thanks a lot but can you give me some documents?
kunkun
|
|
|
|
|
hi,
In codeproject we have lot of articles with example which help to to design user controls. Please do some search for these sort of article here in codeproject.com
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I am using a datagrid in my form
sometimes when a child form of this datagrid form closed
an exception like "Column C does not belong to the table T" was thrown.
this exception is rarely occured so rarely and I can not find the way that
it was generated, so I can not debug the the exception.
does anybody know how to generate this exception and how to handle it.
|
|
|
|
|
hi,
The exception is because you are accessing some column which is doesn't belongs to that perticular table. Reason may you are using datatable which is in form1 to some other form. And the point your are closing the form. The entire object are disposed. See better try to catch your exception and getback to me.
try
{
//Put your logic here
}
catch(exception Ex)
{
MessageBox.Show(Ex.Message.ToString());
}
Check what are the avilable (members) which you are accessing outside your form1 class file.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Thanks for your guide.
I know how can I catch the exceptions in my codes. Also I know if a column does not belong to a table, I couldn't access the column.
But if you read my message again I describe that this error is appeared so rarely. So I couldn't catch it.
regards,
Mehdi
|
|
|
|
|
Control class has an intresting property like Anchor. The SDK Documentation says: "A bitwise combination of the AnchorStyles values. The default is Top and Left". Whatever that means. So what is it ? Some kind of a enumeration ? If I would want to make a property like Anchor then how could I declare it ?
Regards, Desmond
|
|
|
|
|
hi,
Anchoring means keeping the position of the control fixed no matter if the user try to resize the form. You will get the anchoring feature while inheriting any built-in control into your custom controls.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Like the documentation says: It's a combination of AnchorStyles (an enumeration) values.
The AnchorStyles enumeration has the [Flags] attribute set, this means arbitrary combinations of enumeration values can be combined using bitwise OR.
For example:
myControl.Anchor = AnchorStyles.Left|AnchorStyles.Top;
Setting a flag:
myControl.Anchor |= AnchorStyles.Bottom;
Clearing a flag:
myControl.Anchor &= ~AnchorStyles.Bottom;
Testing for a flag:
if ((myControl.Anchor & AnchorStyles.Top) == AnchorStyles.Top) ...
Regards,
mav
|
|
|
|
|
To add to everything else that was posted...
For example, In your class, AnchorStyles will become a data type for an Anchor property that your class exposes. Since you want your enumeration members to be used by outside code, you'll make sure they're public also. Now, when you define to class' Anchor property, you'll do it something like this:
public class myComponent
{
[FlagsAttribute]
public enum AnchorStyles
{
Left = 1,
Top = 2,
Right = 4,
Bottom = 8
};
private AnchorStyles m_Anchor;
public AnchorStyles Anchor
{
get
{
return m_Anchor;
}
set
{
m_Anchor = value;
}
}
}
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i have a button_Click function to add a row to a DataTable , the DataTable Defined in another function called addRC(), which called by the Form_Load
can i access that DataTable in the addRC() from the button_Click() function , and how ?
|
|
|
|
|
hi,
You can access your DataTable variable anywhere in your .cs file or out side. Provided you need to declare as public. say
namespace xxx
{
class form1
{
public Datatable YourDataTable;
}
form_load()
{
//Here declare
YourDataTable=new DataTable();
//then populate your content. i mean run your method.
}
}
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
hi again , i don't want to define a public DataTable any where i want to access that one in the addRC() function
|
|
|
|
|
hi,
addRC() is an user defined function right. Suppose if you want to access any variable inside this sort of user defined function then the variable must be private or protected. And if you want to access variable a variable outside your class then it muct be protected or public.
Other wise declare that member variable as private and use property to get the value. I mean only the Get modifier in your property.
We can't any of local variable which is declared inside a function. Why because it's accessability is only inside that function. Don't feel bad. We have remady for this.Remady is , you can use 'out' modifier to access the value of that local variable which is there in that function.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
here is my code :
in this code i define a public dataTable "t", but the problem is that i dont want to do that , i want to use the DataTable "test" -which is defined in the addDT() function - in the button1_Click
help me please
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication2
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.TextBox textBox1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
private DataTable t = new DataTable();
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.textBox1 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 80);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(0, 141);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(432, 136);
this.dataGrid1.TabIndex = 1;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(208, 80);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 2;
this.textBox1.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(432, 277);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
addDT();
}
private void addDT()
{
DataTable test = new DataTable();
test.Columns.Add();
dataGrid1.DataSource=test;
t = test;
}
private void button1_Click(object sender, System.EventArgs e)
{
t.Rows.Add(getInput());
}
private string[] getInput()
{
string text = textBox1.Text;
string [] input = new string[] {text};
return input;
}
}
}
|
|
|
|
|
hi,
If you don't want then don't declare that public datatable variable. I told different way to achive your result. that's it.
Please re-write your AddDt and form_Load events.
private void addDT(out DataTable Dt)
{
DataTable test = new DataTable();
test.Columns.Add();
dataGrid1.DataSource=test;
Dt=test;
}
private void Form1_Load(object sender, System.EventArgs e)
{
DataTable Dt;
addDT(out Dt);
//Here you will get the DataTable Which is There in your addDT method
}
feel free to ask more questions
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
hi again
now how can i add new row to the DataTable from the button1_Click(.....) ???
|
|
|
|
|
sakkijha wrote:
in this code i define a public dataTable "t",
Please correct me, but I think you declare t as a private member.
sakkijha wrote:
i want to use the DataTable "test" -which is defined in the addDT() function - in the button1_Click
You're already doing this by declaring t = test; and then using t in the button1_Click method. Keep in mind that test is only a reference to the DataTable and t references the same DataTable after the assignment.
You could even spare declaring test:
private void addDT()
{
t = new DataTable();
t.Columns.Add();
dataGrid1.DataSource=t;
}
www.troschuetz.de
|
|
|
|
|
How to convert a a char[] array into a byte[] array? (without converting each char in particular)
Ariadne
|
|
|
|
|
hi,
using System;
class Example
{
public static void Main()
{
Char[] chars = new char[]{'A','B','C','D'};
byte[] br = Converter(chars);
}
unsafe static byte[] Converter(char[] Arr)
{
unsafe
{
byte[] By=new byte[Arr.Length];
fixed(char *p_arr = Arr)
{
char *p_elem = p_arr;
for(int i=0;i
|
|
|
|
|
char[] c = new char[] {'a','b','c'};
byte[] b = System.Text.Encoding.Default.GetBytes(c);
|
|
|
|
|
Hi All,
I am using timer in one of the application I am developing.
When I try to set the interval to "2233860000.0 millisec", I am getting the following exception
"Number must be either non-negative or -1.\r\nParameter name: dueTime"
Here is the code snippet I am using
System.Timers.Timer timerTest = new System.Timers.Timer();
timerTest.Interval = 2200920000.0;
timerTest.Enabled = true;
timerTest.Start();
timerTest.Elapsed +=new System.Timers.ElapsedEventHandler(time_Elapsed);
Thanks in Advance,
Jo
|
|
|
|