|
Dear All,
Currently i am working in winforms, my problem is how to restrict to add new rows into a datagird at runtime
user has permission to add 2 rows only if he wants to add one more row it should restrict
thanks in advance
|
|
|
|
|
Isn't it possible to check the row count? If it is more than the allowed limit, show a message saying "You can't add a new row".
|
|
|
|
|
I have a DropDown in GridView.I populated that DropDown manually via Items and putting those Items in the "Collection".The Items are :Mr and Ms.Its working well and getting populated.
My problem is, while I press the down arrow key from that Cel, the Items get changed i.e,Mr changes to Ms and vice versa despite my requirement. My requirement is that, while we press down arrow Key,the control should Go to Next line of that GridView instead of Items getting changed.
Please Suggest me on this Issue.
Thank you.
|
|
|
|
|
From what you have written it sounds like you are capturing the mouse down that triggers the drop down, but you did not show us how you are trying to go to the next row. From the result you are describing, I am guessing that you might be doing a SendKeys. If that is the case, you might instead try to do something like the following where 0 would be the column/cell number you want to set the focus to when you go to the next row...
if (DataGridView.Rows.Count > (DataGridView.CurrentRow.Index + 1))
DataGridView.CurrentCell = DataGridView.Rows[DataGridView.CurrentRow.Index + 1].Cells[0];
|
|
|
|
|
hi Everyone
I Have drawn a Sine wave using GDI+ in C# windows application, now i need to know how to zoom the Selected region..
can anyone help me? plssssss
|
|
|
|
|
an attempt:
I think there are 2 main things to do.
1. Determin the X1, X2 and Y1, Y2 where you want to zoom too. These are your constraints. (recalculate)
This means in the equation y = A sin (Bx - C) + D that both x and y have to be within the restraints.
2. scale your X-Y axis. if 100 pixels for Amplitude = 1 then you could set it to 200 pixels for amplitude = 1 (eg).
I would recommend doing one first without scaling, if the results are correct, you can rescale the axis to reflect the entire drawing area.
Hope this helps.
(it's been awhile, so double check )
|
|
|
|
|
I have to expand both Sine wave as well as with(in terms of pixels) of the bitmap.
can i have sample code..
|
|
|
|
|
you just work out the sine function for every point along the way.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
skvs wrote: can i have sample code..
will be difficult as it has been a long time I have played with it...
|
|
|
|
|
Sorry i ll explain my question clearly.
1) I have drawn a Sine Wave using Graphics.DrawCurve(..);
2) Now i need to capture (X1,Y1) and (X2, Y2) Vaues on mouse down and mouse Up function, where I'm selecting a particular region of the sinusoidal wave.
(may be upper half cycle).
3) So now i have the values, but i dont know how to enlarge only selected region in GDI+ C#..
plsssss help me.
|
|
|
|
|
Your missing the point. You can't just specify that you want to zoom into an area on the form that you have already drawn, GDI doesn't support this. What you have to do, is clear the form, and redraw the area you want, but bigger.
You can capture x1,y1 x2,y2 mouse coordinates by handling the mouse down or mouse click events.
Now you have the values, clear the form. (by calling .Clear(); on your Graphics object, and redraw your sine wave, bigger, and just the bit within the mouse coordinates you found out.
E.g if your form is 1000 pixels wide and 1000 high, and you've drawn a sign wave from 0 to 360. If the user then picks to zoom in to 0,0 (top left corner) to 500,1000 (bottom in the middle). You need to then work out that 500 represents half way, which is 180 on your x axis. And that 1000 represents the whole distance (i.e. all the way from 1 to -1), you then clear the image, and redraw the sine wave from 0 to 180, but expanded to fill the whole form.
Basically, you need to store scale factors and position factors that you scale and move you sine wave by when redrawing it each time.
Simon
|
|
|
|
|
That was what I was thinking, but you explained it better
|
|
|
|
|
that's a great idea, in fact it is required to draw only part of the sine wave, but how to find which are those points that i need to consider..
int intLenght = 200;<br />
PointF[] pf = new PointF[intLenght];<br />
<br />
for (int intI = 0; intI < intLenght; intI++)<br />
{<br />
int intHeightOffset = 250;<br />
if ((intI%10) > 5)<br />
{<br />
pf[intI] = new PointF(intHeightOffset + intI, (intI % 10) + intHeightOffset);<br />
}<br />
else<br />
{<br />
pf[intI] = new PointF(intHeightOffset + intI, -(intI % 10) + intHeightOffset);<br />
}<br />
}<br />
<br />
Graphics gps = this.CreateGraphics();<br />
gps.DrawCurve(new Pen(Color.DarkBlue), pf);<br />
if i select middle of the graph, from which point's of the array i hv to take to redraw the sine wave..?
pls dont mind, i need ur help..
|
|
|
|
|
some one had deleted me message.
|
|
|
|
|
I have this error "ExecuteReader: Connection property has not been initialized."
Here is my code . Could give me any advice to fix it ?Thanks
private void button1_Click(object sender, EventArgs e)
{
string cmd;
string field;
string parameter;
field = "Site,Model";
parameter = "@Site,@Model";
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");
cmd = "INSERT INTO Run(" + field + ") values (" + parameter + ")";
OleDbCommand sCommand = new OleDbCommand(cmd);
aConnection.Open();
OleDbDataReader aReader = sCommand.ExecuteReader();
sCommand.Parameters.Add("@Site", OleDbType.VarChar, 20);
sCommand.Parameters.Add("@Model", OleDbType.VarChar, 20);
sCommand.Parameters["@Site"].Value = "site1";
sCommand.Parameters["@Model"].Value = "Model1";
aReader.Close();
aConnection.Close();
}
|
|
|
|
|
hung1984 wrote: OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");
cmd = "INSERT INTO Run(" + field + ") values (" + parameter + ")";
OleDbCommand sCommand = new OleDbCommand(cmd);
aConnection.Open();
Look at the error message again and read through the code. How is the command object going to know which connection object to use if you didn't tell it.
|
|
|
|
|
hung1984 wrote: OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");
cmd = "INSERT INTO Run(" + field + ") values (" + parameter + ")";
OleDbCommand sCommand = new OleDbCommand(cmd);
add this
<br />
sCommand.Connection = aConnection;<br />
hope it helps
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
thanks, but i have another error?
"No value given for one or more required parameters."
|
|
|
|
|
hung1984 wrote:
sCommand.Parameters.Add("@Site", OleDbType.VarChar, 20);
sCommand.Parameters.Add("@Model", OleDbType.VarChar, 20);
sCommand.Parameters["@Site"].Value = "site1";
sCommand.Parameters["@Model"].Value = "Model1";
try this :
sCommand.Parameters.Add("@Site", OleDbType.VarChar, 20).Value = "site1";
sCommand.Parameters.Add("@Model", OleDbType.VarChar, 20).Value = "Model1";
hope it helps
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
thanks , but same error occured?
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
{
string cmd;
string field;
string parameter;
field = "Site,Model";
parameter = "@Site,@Model";
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");
cmd = "INSERT INTO Run(" + field + ") values (" + parameter + ")";
OleDbCommand sCommand = new OleDbCommand(cmd);
sCommand.Connection = aConnection;
aConnection.Open();
sCommand.Parameters.Add("@Site", OleDbType.VarChar, 20);
sCommand.Parameters.Add("@Model", OleDbType.VarChar, 20);
sCommand.Parameters["@Site"].Value = "site1";
sCommand.Parameters["@Model"].Value = "Model1";
OleDbDataReader aReader = sCommand.ExecuteReader();
sCommand.Parameters.Add("@Site", OleDbType.VarChar, 20);
sCommand.Parameters.Add("@Model", OleDbType.VarChar, 20);
sCommand.Parameters["@Site"].Value = "site1";
sCommand.Parameters["@Model"].Value = "Model1";
aReader.Close();
aConnection.Close();
}
|
|
|
|
|
just wrong code line position ,
thanks a lot
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
hi to everyone.. anyone suggest me the method to read .mpp file content using C#. and also how we can store content to oracle database.
|
|
|
|
|
Does the office toolkit give you the ability to bridge to project ? If not, then you need to find out the file format and work out how to read it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
In .NET 2.0, assume that I have some SQL written along the lines of:
Select child.name, parent.name
From person child, person parent
On child.ParentId = parent.Id
Where child.category = 55
I now have to convert this SQL so that it selects from a cached DataTable of people instead of directly from the database.
Is there an elegant way to convert this SQL using DataTable.Select (or some other DataTable method)? (I realize that if there was just one Person in the SQL statement this would be simple.)
|
|
|
|