|
If in one side you do:
binaryFormatter.Serialize(connectionStream);
and in the other side you do:
binaryFormatter.Deserialize(connectionStream);
The BinaryFormatter itself will know when it finished receiving the object.
You can also:
Instead of serializing directly, serialize to a MemoryStream. Then, you first send the length of the serialized data (for example, as an WriteLine) and then the data. And, on the other side, you first receive the length of the data, and then creates a buffer and read it to the end. But I really think you don't need that.
|
|
|
|
|
I'm trying something similar to this:
http://msdn.microsoft.com/en-us/library/ms838165.aspx[^]
I used that code to handle de editing:
private void grdOrders_CurrentCellChanged(object sender,
System.EventArgs e)
{
if (!inUpdateMode)
{
if (inEditMode && !grdOrders.CurrentCell.Equals(editCell))
{
inUpdateMode = true;
grdOrders.Visible = false;
DataGridCell currentCell = grdOrders.CurrentCell;
grdOrders[editCell.RowNumber, editCell.ColumnNumber] =
txtEdit.Text;
grdOrders.CurrentCell = currentCell;
grdOrders.Visible = true;
inUpdateMode = false;
txtEdit.Visible = false;
inEditMode = false;
}
editCell = grdOrders.CurrentCell;
txtEdit.Text = (string)grdOrders[editCell.RowNumber,
editCell.ColumnNumber];
Rectangle cellPos = grdOrders.GetCellBounds(editCell.RowNumber,
editCell.ColumnNumber);
txtEdit.Left = cellPos.Left - 1;
txtEdit.Top = cellPos.Top + grdOrders.Top - 1;
txtEdit.Width = cellPos.Width + 2;
txtEdit.Height = cellPos.Height + 2;
txtEdit.Visible = true;
inEditMode = true;
}
}
But I'm having a problem. I dont know what to put on Form1 Design so I'm getting the error:
txtEdit does not exist on current context.
Can you please help me ?
|
|
|
|
|
From the page you referenced:
When a cell is tapped (both inEditMode and inUpdate mode is false), the current cell is saved (editCell). Then, the hidden TextBox (txtEdit) gets the current cell contents, is repositioned to the location of the current cell, and is made visible (over the current cell). When editing is complete and another cell is selected, the event code is disabled (inUpdateMode set to true) and the new cell is saved (currentCell) while the edited cell gets updated from the TextBox control. During the update the grid is not updated (Visible set to false), and when the update is complete the TextBox is hidden again.
If you want to do things the way they did, you need to create the hidden TextBox control named txtEdit on your form.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I need to display information from MS SQL table, and I need to have edit, insert and delete options.
What should I use? ListView? DataGrid..? Or another ?
|
|
|
|
|
You should use DataGrid. It has edit, insert and delete function itself.
|
|
|
|
|
hisen wrote: You should use DataGrid. It has edit, insert and delete function itself.
Thanks! Should I save information with SQL Server CE or XML ?
Can you please point me to information where I can learn to do those operations?
|
|
|
|
|
I think you needn't. But it depend on your project specfic request.
|
|
|
|
|
|
|
Hello,
Can anyone explain me how to build ListView from SQL Query? (MS SQL Server)
|
|
|
|
|
Hi all,
I have an xml file that I want to make a small app to present its contents in a convenient way to the user. Nothing especially fancy is needed here - a pane for a treeview so the user can select what he or she wants to look at, a panel for displaying the selection(s), and the facility to load the file in the first place.
I'm thinking this would be a good time for me to get familiar with linq2xml (linq noob here), but wanted to see if there were other equally-or-better good routes to go as well.
Thx!
-sff
|
|
|
|
|
sherifffruitfly wrote: a pane for a treeview
Why not simply load the whole XML document into the TreeView?
|
|
|
|
|
No major reason - I just think of treeview data situations a 2-paned affairs is all. Possibly that's an out-moded frame of mind.
I was more interested in alternative methods of getting the data to the app in the first place though, I can fiddle with it once it's there in a variety of ways.
|
|
|
|
|
Hello, I do not know why it is happening, but sometimes DateTime.Substract returns either 0 or 1, while parameter have same values
public bool bCodeChange1;
public bool bCodeChange2;
private DateTime RemoveTime(DateTime time)
{
time = time.AddHours(-time.Hour);
time = time.AddMilliseconds(-time.Millisecond);
time = time.AddMinutes(-time.Minute);
time = time.AddSeconds(-time.Second);
return time;
}
private void dateTimePickerDateDeadLine_ValueChanged(object sender, EventArgs e)
{
DateTime dtDateDeadLine = dateTimePickerDateDeadLine.Value;
DateTime dtDateReciet = dateTimePickerDateReciet.Value;
dtDateDeadLine = RemoveTime(dtDateDeadLine );
dtDateReciet = RemoveTime(dtDateReciet );
if (dtDateRecit >= dtDateDeadLine )
{
MessageBox.Show("DeadLine need to be at least one day ahead of Reciet", "Račun", MessageBoxButtons.OK);
dateTimePickerDateDeadLine.Value = dtDateReciet.AddDays(1);
return;
}
if (bCodeChange2)
{
bCodeChange2 = false;
return;
}
bCodeChange1 = true;
numericUpDownDaysTillDeadLine.Value = dtDateDeadLine.Subtract(dtDateReciet).Days + 1;
}
private void numericUpDownDaysTillDeadLine_ValueChanged(object sender, EventArgs e)
{
if (bCodeChange1)
{
bCodeChange1 = false;
return;
}
bCodeChange2 = true;
numericUpDownDaysTillDeadLine.Value = dateTimePickerDateReciet.Value.AddDays(Convert.ToDouble(numericUpDownDaysTillDeadLine.Value));
}
I am so puzzled. Thanks goes in Advance.
PS: If variables names missmatches, you do not need to point out, because i nearly translated variable names, so that you can understand.
|
|
|
|
|
Saksida Bojan wrote: numericUpDownDaysTillDeadLine.Value = dtDateDeadLine.Subtract(dtDateReciet).Days + 1;
In your example above this should return zero, as the Subtract() method returns -1; dtDateDeadLine is smaller (i.e. less than) dtDateReciet . If the dates are equal then Subtract() will return zero giving a final answer of 1.
|
|
|
|
|
Saksida Bojan wrote: i nearly translated variable names
not a good idea in general
One problem you have is DateTime contains time up to a single tick, that's a tenth of a microsecond.
To strip the time, just use DateTime.Date
In general, when in trouble with a particular class, read the first 3 MSDN pages about that class, including the list of methods, properties and events.
|
|
|
|
|
Thank you, it worked like a charm.
|
|
|
|
|
you're welcome.
|
|
|
|
|
Good afternoon.
I was wondering if there is a more efficient way to write this code:
if (cboSP_Site.SelectedIndex == -1 && inttmpSP != -1)
{
WebBrowser1.GoBack();
}
else if (cboWS.SelectedIndex == -1 && inttmpWS != -1)
{
WebBrowser1.GoBack();
}
else if (cboFolder.SelectedIndex == -1 && inttmpF != -1)
{
WebBrowser1.GoBack();
}
I want to call the WebBrowser1.GoBack(); once if possible.
Thank you, WHEELS
|
|
|
|
|
Wheels012 wrote:
I want to call the WebBrowser1.GoBack(); once if possible.
Do nested If
if (cboSP_Site.SelectedIndex == -1)
{
if (inttmSP != -1 || inttmpWS != -1 || inttmpF != -1)
WebBrowser1.GoBack();
}
I hope i did it correctly
|
|
|
|
|
Saksida Bojan wrote: I hope i did it correctly
Not really. Every letter counts here.
|
|
|
|
|
there are many ways to get what you want, here is one:
if ((cboSP_Site.SelectedIndex == -1 && inttmpSP != -1) ||
(cboWS.SelectedIndex == -1 && inttmpWS != -1) ||
(cboFolder.SelectedIndex == -1 && inttmpF != -1)) {
WebBrowser1.GoBack();
}
and another one:
bool goBack=false;
if (cboSP_Site.SelectedIndex == -1 && inttmpSP != -1) goBack=true;
else if (cboWS.SelectedIndex == -1 && inttmpWS != -1) goBack=true;
else if (cboFolder.SelectedIndex == -1 && inttmpF != -1)) goBack=true;
if (goBack) WebBrowser1.GoBack();
BTW: here the "else" keywords are optional
modified on Monday, November 30, 2009 4:23 PM
|
|
|
|
|
Thank you Luc.
if ((cboSP_Site.SelectedIndex == -1 && inttmpSP != -1) ||
(cboWS.SelectedIndex == -1 && inttmpWS != -1) ||
(cboFolder.SelectedIndex == -1 && inttmpF != -1)) {
WebBrowser1.GoBack();
}
Is what I am looking for. A little slow today.
WHEELS
|
|
|
|
|
5 years from now, you'll probably be scratching your head over what this code does. At the risk of being chastised for writing more code, I suggest you amend the code to:
bool itemDeleted = (cboSP_Site.SelectedIndex == -1 && inttmpSP != -1) ||
(cboWS.SelectedIndex == -1 && inttmpWS != -1) ||
(cboFolder.SelectedIndex == -1 && inttmpF != -1);
if (itemDeleted) {
WebBrowser1.GoBack();
} /ravi
|
|
|
|
|