|
I have a DataGrid bound to an Access 2K database
entering a time in the grid either via a DatetimePicker or directly into the
field the time displays Ok on the grid but will not update the database
using a DateTimepicker I can see that the value is a string all types in
code and XML schema are dateTime, I have saved the time back to a string
field OK
2 date/time fields formatted dd/mm/yyyy HH:mm in Access - same problem when
formatted at short time and Gener
jnc
|
|
|
|
|
Hi
I have a button named button1 on my form, and this is its evetn handler code:
private void button1_Click(object sender, System.EventArgs e)
{
button1.Location.X += 10;
}
but compiler tells me:
Cannot modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable
Why can't we change the X and Y properties of a Point object?
|
|
|
|
|
Anonymous wrote:
Why can't we change the X and Y properties of a Point object?
Becuase a Point is a valuetype. You will need to reassign the Location to a modifeid Point object.
top secret xacc-ide 0.0.1
|
|
|
|
|
It doesn't make sense at all! Why should we always make a new instance just to change a single property? It's really ridiculous!
|
|
|
|
|
|
I craete an usercontrol that have this property :
public enum enumShowState{horizantal,vertical} ;<br />
private enumShowState m_showState ;<br />
public enumShowState ShowState<br />
{<br />
get{return m_showState;}<br />
set<br />
{<br />
m_showState=value;<br />
SetShowState(value) ;<br />
}<br />
}
when i use it in my other project, this filtered error will be show :
Projects\mph\frmStudAnswer.cs(111): The variable 'enumShowState' is either undeclared or was never assigned.
and when i click on this error, cursor go to this source code :
public class frmStudAnswer : System.Windows.Forms.Form<br />
{<br />
...<br />
...<br />
private void InitializeComponent()<br />
{<br />
<br />
....<br />
...<br />
this.UserControl1.ShowState = Share.UserControl1.enumShowState.horizantal;<br />
... <br />
...<br />
}<br />
...<br />
}
note that i referenced to my UserControl1 project.
please guide me.
|
|
|
|
|
hd_ali@yahoo.com wrote:
this.UserControl1.ShowState = Share.UserControl1.enumShowState.horizantal;
Try not calling your instances the same names as classes (how about some proper names?). This AFAI concerned a resolution bug in C# compiler, that appears in more than one place.
top secret xacc-ide 0.0.1
|
|
|
|
|
How can I get the address of an object (as IntPtr) or any other variable type ?
Though I could get a variable address in unsafe,
(or maybe there is a better c# way ... I dont know)
unsafe
{
int x=0;
int *p=&x;
}
With objects it's not working, and still I have to convert it from int* to IntPtr ...
Thanks
|
|
|
|
|
|
GCHandle hnd = GCHandle.Alloc(object);
InPtr ptr = hnd.AddrOfPinnedObject();
But seriously what are you going to do with it ?
|
|
|
|
|
If you are trying to read the contents of a specific address without knowing what type of data is held there, then one way of doing it is to call:
Marshal.PtrToStringAnsi(ptr, length)
where 'ptr' represents the address of the first byte and 'length' the number of bytes to be read.
This returns the data in the form of a managed string (with each byte expanded to a 2-byte unicode character), which you can then examine
Naveen
|
|
|
|
|
i need help in dot net relating to mobile computing ..
i need to connect my server from mobile using c# and perform some functions on server from mobile..
where I can get resourses and what i need to study ........ urgent help ..
do best whereever you are...
|
|
|
|
|
Hi,
I put a DataGrid in form and I can browse the fields of a query. Now I want to show some string contents istead of numeric values of a field.
For example I have a field Enabled with (0/1) values and I want to show Enabled/Disabled instead of 0/1 numbers.
How can I do it?
Mehdi
|
|
|
|
|
I'm working on application, that will recive multiple Excel files
and displaing it in a DataGrid.
The problem is, that when I select 2 or 3 files from OpenDialog, it
displays only the data from the first selected file, the other values
in DataGrid are null values. Why is that? And how can I solve this, that
the DataGrid will display all values. Thank you.
Here is the code:
private void btnOpen_Click(object sender, System.EventArgs e)
{
try
{
Stream myStream;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "E:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt|Allfiles(*.*)|*.*" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;
openFileDialog1.Multiselect = true;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
if((myStream = openFileDialog1.OpenFile())!= null)
{
DataSet ds = new DataSet();
foreach (string strFileName in openFileDialog1.FileNames)
{
string connStr =
@"Driver={Microsoft Excel Driver (*.xls)};DBQ=" + strFileName;
string sql = "SELECT * FROM [Sheet1$]";
OdbcDataAdapter adapter = new OdbcDataAdapter(sql,connStr);
adapter.Fill(ds,"[Sheet1$]");
}
gridPorocila.DataMember = "[Sheet1$]";
gridPorocila.DataSource = ds.DefaultViewManager;
myStream.Close();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
|
|
|
|
|
how do you turn a 'Text' into a number variable since I wanted to get some input through textboxes and do mathamatical operations on them, and what is the namespace for mathamatical operations by the ways?
|
|
|
|
|
Sry I forgot to mention Im using VS.NET 2005 beta 1 with the .net framework v2.0 so if anyone has this problem email me..
|
|
|
|
|
Sry again, I figured it out but now I have another (?) how would you convert a string into an integer or double or whatever??
|
|
|
|
|
By using the Convert[^] class.
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
Thx but now I don't have any errors exept
Error 3 Cannot implicitly convert type 'uint' to 'string'
|
|
|
|
|
This is something like what I have.
UInt32 A = 0;<br />
UInt32 O = 0;<br />
A = Convert.ToUInt32(tbA.Text);<br />
O = Convert.ToUInt32(tbO.Text);<br />
tbResults.Text = A/O;<br />
tbResults.Text = Math.Pow(A, 2)/Math.Sqrt(O);
Error 3 Cannot implicitly convert type 'uint' to 'string'
|
|
|
|
|
just use a cast...
UInt32 A = 0;<br />
UInt32 O = 0;<br />
A = Convert.ToUInt32(tbA.Text);<br />
O = Convert.ToUInt32(tbO.Text);<br />
tbResults.Text = (string)(A/O);<br />
tbResults.Text = (string)(Math.Pow(A, 2)/Math.Sqrt(O));
if these inputs are coming from a textbox, which it looks like they are, you should consider putting a try/catch block around those Convert statements to make sure the input is valid:
UInt32 A = 0;<br />
UInt32 O = 0;<br />
try<br />
{<br />
A = Convert.ToUInt32(tbA.Text);<br />
}<br />
catch<br />
{<br />
tbA.Text = "0";<br />
A = 0;<br />
}<br />
try<br />
{<br />
O = Convert.ToUInt32(tbO.Text);<br />
}<br />
catch<br />
{<br />
tbO.Text = "0";<br />
O = 0;<br />
}<br />
tbResults.Text = A/O;<br />
tbResults.Text = Math.Pow(A, 2)/Math.Sqrt(O);
I have always used Parse, such as UInt32.Parse(string); instead of Convert, so I'm not sure if it will handle incorrect strings or not, but this is good just to make sure. Obviously you don't have to use 0 to assign to A and O in the try/catch blocks, you can make them whatever you want. Good luck!
|
|
|
|
|
DougW48 wrote:
have always used Parse, such as UInt32.Parse(string); instead of Convert,
Convert is safer than parse IIRC, in the sense that it wont throw an exception. Could be wrong
top secret xacc-ide 0.0.1
|
|
|
|
|
You're probably right, I've never used Convert. Thanks!
|
|
|
|
|
Error 1 Cannot implicitly convert type 'uint' to 'string'
It still says that even if I had it like DougW48's example... I don't know can this be a bug since I'm testing out Visual Studio 8 2005 beta 1
|
|
|
|
|
NVM I got it, anyways Thx for the quick help I got at codeproject, will be visiting this site more often;P
|
|
|
|