Changing TextBox left margin
Hello,
How can I change the TextBox's left margin so I can create
an inherited class from TextBox and paint something on its
left side?
Thank you.
Celio C Jr Tag: Serialiazing a form Tag: 61768
How can I capture rows changing in datagrid (winforms) when arrow up/down is pressed?
I update a form with labels and text boxes when the user clicks on the
rowheader of my winforms datagrid. I notice that the user can move to
a new row using the arrow up/down keys. I currently update the form
using the click event of the datagrid. How can I update the form when
the user moves to a new row using the arrow keys? In other words, I
need to capture the arrow keys when the datagrid is active or when a
new row is selected. BTW, I am using C#, however, if a VB.Net
developer has a solution, please reply. I can always convert the
code. Tag: Serialiazing a form Tag: 61758
SqlDataAdapter.RowUpdated Event
Hi,
Strangely enough, I cannot get the RowUpdated and RowUpdating events of a SqlDataAdapter to fire. I have done the standard subscribing to the event, and connecting the event handlers. But nothing happens.
Any help would be greatly appeciated.
Thanks,
Mark
Within a procedure:
daPersonPhone.RowUpdated +=new SqlRowUpdatedEventHandler(OnRowUpdated);
daPersonPhone.RowUpdating +=new SqlRowUpdatingEventHandler(OnRowUpdating);
The event handlers:
private void OnRowUpdated(object sender, SqlRowUpdatedEventArgs e)
{
if (e.StatementType == StatementType.Insert)
{
if (e.RecordsAffected == 1)
{
int newOrderID = (int)e.Row["OrderID"];
DataRow newRow = dsOriginal.Tables["Phone"].Rows.Find(dummyPhoneID);
newRow["OrderID"] = newOrderID;
}
}
}
private void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e)
{
if (e.StatementType == StatementType.Insert)
dummyPhoneID = (int)e.Row["PhoneID", DataRowVersion.Current];
}
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources... Tag: Serialiazing a form Tag: 61755
Web Services: How slow/fast they are
Subject: Windows distributed app
Data layer: SQL Server ( on separate machine )
Middle layer: WebServices on IIS ( on separate machine )
Questions:
1) How much Web Service are faster/slower compared to
other solutions for middle layer. Are there some (
benchmark or similar ) results which can at least
indicate me that figures.
2) How to configure Web Server ( machine resoureces and
Set up ) to get fastes possible Web Server - Web Services
response. The case could be system with up to 200 WinForm
Clients.
Thank you in advance
Gisa Tag: Serialiazing a form Tag: 61754
IDisposable, using(), RAII and structs [Discussion]
Last night I had several thought about RAII and want to discuss a bit.
Why doesn't CSharp support destructors in structs? Wouldn't that make RAII
possible like in C++? When the struct goes out of scope, the dtor could be
immediately be called (no GC needed).
For that, you don't have to declare the whole File class as a struct (which
would be not good for performance when File has a lot of data-members).
Instead creating a thin wrapper would be a good solution:
public struct MyFile
{
File f;
public MyFile(string p) { f=new File(p); }
~MyFile() { f.Close(); }
}
That would do it.
I have a second though which got through my mind. What about introducing an
interface which is recognized by the compiler and forces usage of the
using() statement.
public interface IDisposableForce : IDisposable{}
A second possibility could be declaring an attribute which marks
IDisposable-implementing-classes wheather using() should be mandatory or at
least suggested.
enum WarnLevel {NoWarn,WarnLvl1,WarnLvl2,WarnLvl3,WarnLvl4,GenerateError};
class UsingAttribute{UsingAttribute(WarnLevel w){}}
[Using(WarnLvl3)] // that means if warnlevel 3 or higher is set a warning
is issued when this class is used without using()-statement
public class MyFile : File
{
public class MyFile(string p) :base(p){}
}
What do you think?
--
cody
[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk Tag: Serialiazing a form Tag: 61739
Selecting Text
I have a basic app that draws some text: Graphics.DrawString(...).
I want to be able to mouse select that text and copy to clipboard. Does
anyone know of any sample info on doing that.
Thank you. Tag: Serialiazing a form Tag: 61733
Full dataset into an empty SQL table
Hi,
I managed to create a SQL server database and a table in it. The table is
empty and that brings me to my next chalenge:
How can I get the info in the table in the dataset to go in an empty SQL
table?
Is there a short way like the FILL method to get data into the dataset or do
I have to read each datarow in the table and write it one at the time to the
database?
rg,
Eric Tag: Serialiazing a form Tag: 61724
[urgent] Message Box is non-modal in VB!
Hi,
In some situation, the message box can not be shown in modal mode.
Please drop a DateTimePicker control on a Form (VB project), show a
message box in the ValueChanged event, as below snippet. Now run the form
and drop down the calendar, select a date to let the event fire, after the
message box shown, we can still activate the form background. This happens
whatever MsgBoxStyle is specified even as MsgBoxStyle.SystemModal.
Private Sub DateTimePicker1_ValueChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles DateTimePicker1.ValueChanged
MsgBox("DateTimePicker1_ValueChanged", MsgBoxStyle.ApplicationModal)
End Sub
The same scenario could be reproduced in a C# project, but I could pass it
if by specifying the Form as the owner of the message box, as below code.
private void dateTimePicker1_ValueChanged(object sender, System.EventArgs
e)
{
MessageBox.Show(this, "dateTimePicker1_ValueChanged");
}
Is something wrong in the message box method in VB?
-jason Tag: Serialiazing a form Tag: 61721
Button.TextAlign bug?
Hi,
I'm using C# and VS.net 2003. When adding a button to a
form using the designer, the default TextAlign value is
always set to MiddleCenter (which is fine). However, if I
change the font to be bold, the text is no longer center-
aligned, it is always a bit off to the right, more or
less depending on the string value. The TextAlign
property is still MiddleCenter though. Is this a known
bug?
Thanks,
Henrik Tag: Serialiazing a form Tag: 61711
A From won't close (c#)
Hello everyone,
I have main application form (child of System.Windows.Forms.Form) that
hosts quite a number of different visual components. Some time after
working with those components, the form refuses to be closed - I click
menu item that invokes Form.Close() method, I click 'close' icon on
the caption of the window (form) - nothing happens. No event comes to
Form_Closing(Object, CancelEventArgs) method either.
I'm at a loss how to even start debugging this situation and I would
appreciate any suggestions.
Thank you for your time,
Yuriy ZUbarev Tag: Serialiazing a form Tag: 61707
DataReader and ListBox
oh come on. I have to be missing something.
There HAS to be a better way of binding data to a winform listbox that
reading through all the records and adding each item to the items
collection.
Its .NET for crying out loud. Tag: Serialiazing a form Tag: 61706
How to force window to Maximize
Hi,
I would like to force my application to maximize when it is launched. I
have tried this by setting the WindowState in the designer at runtime, and
have also tried executing
WindowState = FormWindowState.Normal
The form does open maximized but it does not correctly maximize to the
Windows taskbar...the bottom of the form is lost under the taskbar. If I
use the form control menu to set the form to normal and then back to
maximized, it correctly fits into the available desktop area, only going up
to the top of the taskbar. Any ideas why???
Also I want to stop the user setting the window state to normal - I either
want it maximized or minimized, but never normal. If the user
double-clicks the Window title it does set the window state to normal. Is
there an easy way to prevent this from happening???
Many thanks. Tag: Serialiazing a form Tag: 61704
Check for illegal char in DataGridTextBoxColumn
Hi all, need some help in taking the right approach to
solve this problem.
I have a DataGrid bound to a DataTable. I need the user to
enter only numerical values and decimal. I did override
the ProcessCmdKey of DataGrid. I'm capturing Enter, Tab,
directinal and other keys. If the user enters an invalid
key, I need to prompt him. But, for this I'll need to map
all the other keys to be invalid in my code. Is there any
other slick way of doing this.
Code attached.
protected override bool ProcessCmdKey(ref Message msg,
Keys keyData)
{
const int WM_KEYDOWN = 0x100;
const int WM_SYSKEYDOWN = 0x104;
int rowNum = dGInput.CurrentCell.RowNumber;
int colNum = dGInput.CurrentCell.ColumnNumber;
if ((colNum == 2) || (colNum == 5))
{
if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
switch(keyData)
{
case Keys.D0:
case Keys.D1:
case Keys.D2:
case Keys.D3:
case Keys.D4:
case Keys.D5:
case Keys.D6:
case Keys.D7:
case Keys.D8:
case Keys.D9:
case Keys.NumPad0:
case Keys.NumPad1:
case Keys.NumPad2:
case Keys.NumPad3:
case Keys.NumPad4:
case Keys.NumPad5:
case Keys.NumPad6:
case Keys.NumPad7:
case Keys.NumPad8:
case Keys.NumPad9:
case Keys.Decimal:
case Keys.OemPeriod:
break;
case Keys.Back:
break;
case Keys.Down:
case Keys.Up:
case Keys.Left:
case Keys.Right:
case Keys.Enter:
case Keys.Tab:
UpdateDataGridCell(rowNum,colNum);
break;
default:
MessageBox.Show("Invalid character","Error");
break;
}
}
} Tag: Serialiazing a form Tag: 61703
Application Addins
I am interested in some resources to help in whether or not Addins to a
Windows Forms application is a good (solid) design to add functionality to
the application and also understanding the if anyone has had good and or bad
experiences.
Thanks in advance for all that participate.
Wade Tag: Serialiazing a form Tag: 61700
MSDN Sample - The ListManager's position must be equal to rowNum
Hi All,
I used DataGridComboBoxColumn from MSDN magazine (
http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx).
Normally things work fine.
but in the following cases I get an error 'The ListManager's
position must be equal to rowNum'.
================================
1) when I click on a comboboxcolumn cell
2) and scroll the datagrid
3) and click on another comboboxcolumn cell
OR
1) navigate to a tabpage other than the one datagrid is on
2) and navigate back to datagrid tabpage
3) and click on a comboboxcolumn cell
================================
Good news is I made a change to the code and the problem went away.
The bad news is I can't understand why!
Just wonder if the experts here might be able to help?
The change that I made to DataGridComboBoxColumn are
1) remove combobox.hide from datagrid_scroll event
2)add code in edit method to hide the combo when current cell is not
visible
(I'll attach both codes)
I have trace output for the following sequence of action
1) click on datagridcombobox column cell at row 3 (index 2)
2) then click on datagridcombobox column cell at row 5 (index 4)
3)scroll one cell
4)then click on datagridcombobox column cell at row 6 (index 5)
==============TRACE OUTPUT ORIGINAL CODE====================raises
the error
Edit 2
Leave: column1 column1
SetColumnValueAtRow 2 column1
Edit 4
-------------I scroll now
Edit 4
Leave: column1 column1
SetColumnValueAtRow 4 column1
Scroll
-------------combo hidden is hidden now
Leave: column1 column1
SetColumnValueAtRow 4 column1
Edit 4 <------things start to go wrong here? why is it entering edit
4...when it should be going to edit 5
Edit 5
Leave: column1 column1
SetColumnValueAtRow 4 column1
===============TRACE OUTPUT MODIFIED CODE====================no
errors raised here
Edit 2
Leave: column1 column1
SetColumnValueAtRow 2 column1
Edit 4
-------------scroll
Edit 4
Leave: column1 column1
SetColumnValueAtRow 4 column1
Scroll
-------------combo stays
Leave: column1 column1
SetColumnValueAtRow 4 column1
Edit 5
==================================
notice that things start to go a bit crazy in last 3-4 lines. The thing that
seems to cause the error is Edit method being called in the first case for
rowindex 4 and then rowindex5 immediately....unlike the second case....
It may not make much sense w/o the code so I attach both cases with the
mail.
====================ORIGINAL CODE===================
// Derive class from DataGridTextBoxColumn
public class DataGridComboBoxColumn : DataGridTextBoxColumn
{
// Hosted ComboBox control
private ComboBox comboBox;
private CurrencyManager cm;
private int iCurrentRow;
// Constructor - create combobox, register selection change event handler,
// register lose focus event handler
public DataGridComboBoxColumn()
{
this.cm = null;
// Create ComboBox and force DropDownList style
this.comboBox = new ComboBox();
this.comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
// Add event handler for notification of when ComboBox loses focus
this.comboBox.Leave += new EventHandler(comboBox_Leave);
}
// Property to provide access to ComboBox
public ComboBox ComboBox
{
get { return comboBox; }
}
// On edit, add scroll event handler, and display combo box
protected override void Edit(System.Windows.Forms.CurrencyManager source,
int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string
instantText, bool cellIsVisible)
{
Debug.WriteLine(String.Format("Edit {0}", rowNum));
base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
if (!readOnly && cellIsVisible)
{
// Save current row in the datagrid and currency manager associated with
// the data source for the datagrid
this.iCurrentRow = rowNum;
this.cm = source;
// Add event handler for datagrid scroll notification
this.DataGridTableStyle.DataGrid.Scroll += new
EventHandler(DataGrid_Scroll);
// Site the combo box control within the bounds of the current cell
this.comboBox.Parent = this.TextBox.Parent;
Rectangle rect = this.DataGridTableStyle.DataGrid.GetCurrentCellBounds();
this.comboBox.Location = rect.Location;
this.comboBox.Size = new Size(this.TextBox.Size.Width,
this.comboBox.Size.Height);
// Set combo box selection to given text
this.comboBox.SelectedIndex =
this.comboBox.FindStringExact(this.TextBox.Text);
// Make the ComboBox visible and place on top text box control
this.comboBox.Show();
this.comboBox.BringToFront();
this.comboBox.Focus();
}
// else
// {
// this.comboBox.Hide();
// }
}
// Given a row, get the value member associated with a row. Use the value
// member to find the associated display member by iterating over bound
datasource
protected override object
GetColumnValueAtRow(System.Windows.Forms.CurrencyManager source, int rowNum)
{
//Debug.WriteLine(String.Format("GetColumnValueAtRow {0}", rowNum));
// Given a row number in the datagrid, get the display member
object obj = base.GetColumnValueAtRow(source, rowNum);
// Iterate through the datasource bound to the ColumnComboBox
// Don't confuse this datasource with the datasource of the associated
datagrid
CurrencyManager cm = (CurrencyManager)
(this.DataGridTableStyle.DataGrid.BindingContext[this.comboBox.DataSource]);
// Assumes the associated DataGrid is bound to a DataView, or DataTable that
// implements a default DataView
DataView dataview = ((DataView)cm.List);
int i;
for (i = 0; i < dataview.Count; i++)
{
if (obj.Equals(dataview[i][this.comboBox.ValueMember]))
break;
}
if (i < dataview.Count)
return dataview[i][this.comboBox.DisplayMember];
return DBNull.Value;
}
// Given a row and a display member, iterating over bound datasource to find
// the associated value member. Set this value member.
protected override void
SetColumnValueAtRow(System.Windows.Forms.CurrencyManager source, int rowNum,
object value)
{
Debug.WriteLine(String.Format("SetColumnValueAtRow {0} {1}", rowNum,
value));
object s = value;
// Iterate through the datasource bound to the ColumnComboBox
// Don't confuse this datasource with the datasource of the associated
datagrid
CurrencyManager cm = (CurrencyManager)
(this.DataGridTableStyle.DataGrid.BindingContext[this.comboBox.DataSource]);
// Assumes the associated DataGrid is bound to a DataView, or DataTable that
// implements a default DataView
DataView dataview = ((DataView)cm.List);
int i;
for (i = 0; i < dataview.Count; i++)
{
if (s.Equals(dataview[i][this.comboBox.DisplayMember]))
break;
}
// If set item was found return corresponding value, otherwise return
DbNull.Value
if(i < dataview.Count)
s = dataview[i][this.comboBox.ValueMember];
else
s = DBNull.Value;
base.SetColumnValueAtRow(source, rowNum, s);
}
// On datagrid scroll, hide the combobox
private void DataGrid_Scroll(object sender, EventArgs e)
{
Debug.WriteLine("Scroll");
this.comboBox.Hide();
}
// On combo box losing focus, set the column value, hide the combo box,
// and unregister scroll event handler
private void comboBox_Leave(object sender, EventArgs e)
{
DataRowView rowView = (DataRowView) this.comboBox.SelectedItem;
string s = (string) rowView.Row[this.comboBox.DisplayMember];
Debug.WriteLine(String.Format("Leave: {0} {1}", this.comboBox.Text, s));
SetColumnValueAtRow(this.cm, this.iCurrentRow, s);
Invalidate();
this.comboBox.Hide();
this.DataGridTableStyle.DataGrid.Scroll -= new
EventHandler(DataGrid_Scroll);
}
}
===================================MODIFIED
CODE=========================================
// Derive class from DataGridTextBoxColumn
public class DataGridComboBoxColumn : DataGridTextBoxColumn
{
// Hosted ComboBox control
private ComboBox comboBox;
private CurrencyManager cm;
private int iCurrentRow;
// Constructor - create combobox, register selection change event handler,
// register lose focus event handler
public DataGridComboBoxColumn()
{
this.cm = null;
// Create ComboBox and force DropDownList style
this.comboBox = new ComboBox();
this.comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
// Add event handler for notification of when ComboBox loses focus
this.comboBox.Leave += new EventHandler(comboBox_Leave);
}
// Property to provide access to ComboBox
public ComboBox ComboBox
{
get { return comboBox; }
}
// On edit, add scroll event handler, and display combo box
protected override void Edit(System.Windows.Forms.CurrencyManager source,
int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string
instantText, bool cellIsVisible)
{
Debug.WriteLine(String.Format("Edit {0}", rowNum));
base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
if (!readOnly && cellIsVisible)
{
// Save current row in the datagrid and currency manager associated with
// the data source for the datagrid
this.iCurrentRow = rowNum;
this.cm = source;
// Add event handler for datagrid scroll notification
this.DataGridTableStyle.DataGrid.Scroll += new
EventHandler(DataGrid_Scroll);
// Site the combo box control within the bounds of the current cell
this.comboBox.Parent = this.TextBox.Parent;
Rectangle rect = this.DataGridTableStyle.DataGrid.GetCurrentCellBounds();
this.comboBox.Location = rect.Location;
this.comboBox.Size = new Size(this.TextBox.Size.Width,
this.comboBox.Size.Height);
// Set combo box selection to given text
this.comboBox.SelectedIndex =
this.comboBox.FindStringExact(this.TextBox.Text);
// Make the ComboBox visible and place on top text box control
this.comboBox.Show();
this.comboBox.BringToFront();
this.comboBox.Focus();
}
else
{
this.comboBox.Hide();
}
}
// Given a row, get the value member associated with a row. Use the value
// member to find the associated display member by iterating over bound
datasource
protected override object
GetColumnValueAtRow(System.Windows.Forms.CurrencyManager source, int rowNum)
{
//Debug.WriteLine(String.Format("GetColumnValueAtRow {0}", rowNum));
// Given a row number in the datagrid, get the display member
object obj = base.GetColumnValueAtRow(source, rowNum);
// Iterate through the datasource bound to the ColumnComboBox
// Don't confuse this datasource with the datasource of the associated
datagrid
CurrencyManager cm = (CurrencyManager)
(this.DataGridTableStyle.DataGrid.BindingContext[this.comboBox.DataSource]);
// Assumes the associated DataGrid is bound to a DataView, or DataTable that
// implements a default DataView
DataView dataview = ((DataView)cm.List);
int i;
for (i = 0; i < dataview.Count; i++)
{
if (obj.Equals(dataview[i][this.comboBox.ValueMember]))
break;
}
if (i < dataview.Count)
return dataview[i][this.comboBox.DisplayMember];
return DBNull.Value;
}
// Given a row and a display member, iterating over bound datasource to find
// the associated value member. Set this value member.
protected override void
SetColumnValueAtRow(System.Windows.Forms.CurrencyManager source, int rowNum,
object value)
{
Debug.WriteLine(String.Format("SetColumnValueAtRow {0} {1}", rowNum,
value));
object s = value;
// Iterate through the datasource bound to the ColumnComboBox
// Don't confuse this datasource with the datasource of the associated
datagrid
CurrencyManager cm = (CurrencyManager)
(this.DataGridTableStyle.DataGrid.BindingContext[this.comboBox.DataSource]);
// Assumes the associated DataGrid is bound to a DataView, or DataTable that
// implements a default DataView
DataView dataview = ((DataView)cm.List);
int i;
for (i = 0; i < dataview.Count; i++)
{
if (s.Equals(dataview[i][this.comboBox.DisplayMember]))
break;
}
// If set item was found return corresponding value, otherwise return
DbNull.Value
if(i < dataview.Count)
s = dataview[i][this.comboBox.ValueMember];
else
s = DBNull.Value;
base.SetColumnValueAtRow(source, rowNum, s);
}
// On datagrid scroll, hide the combobox
private void DataGrid_Scroll(object sender, EventArgs e)
{
Debug.WriteLine("Scroll");
// this.comboBox.Hide();
}
// On combo box losing focus, set the column value, hide the combo box,
// and unregister scroll event handler
private void comboBox_Leave(object sender, EventArgs e)
{
DataRowView rowView = (DataRowView) this.comboBox.SelectedItem;
string s = (string) rowView.Row[this.comboBox.DisplayMember];
Debug.WriteLine(String.Format("Leave: {0} {1}", this.comboBox.Text, s));
SetColumnValueAtRow(this.cm, this.iCurrentRow, s);
Invalidate();
this.comboBox.Hide();
this.DataGridTableStyle.DataGrid.Scroll -= new
EventHandler(DataGrid_Scroll);
}
}
Thanks if you've got here... :-)
GK Tag: Serialiazing a form Tag: 61697
typed dataset on inherited form
There is obviously a bug in VS.NET 2003:
Steps to reproduce:
1.) Create typed DataSet with one unique key.
2.) Make WinForm and place a (visual) instance of the
typed DataSet on it.
3.) Create an inherited form (base on the first form).
4.) Place any control (button,...) on the second form.
When running the test-app, an exception is thrown.
(System.ArgumentException: Cannot add primary key
constraint since primary key is already set for the
table.)
Reason: VS generates code in the inherited form for the
dataset, which will add the same constraint again to the
dataset.
I found a thread, reporting this topic:
http://groups.google.at/groups?threadm=009801c31794%
24f74a5bb0%242f01280a%40phx.gbl
This thread is from May 03 and it says, that this is a
known bug and a KB-article regarding this issue is going
to be published. But I could not find anything! :(
Are there any solutions to this problem yet???
Thanks for any answer!!
Thomas Tag: Serialiazing a form Tag: 61696
window form style question
I am using VS.net 2003 to develop a simple window form by
using C#. I have added a menu in that simple window, as
follow:
http://destiny.xfiles.to/ubbthreads/files/383648-2.jpg
The style is the standard one, but i would like to change
to VS.net style, just like the following:
http://destiny.xfiles.to/ubbthreads/files/383646-1.jpg
how can i change the standard style to VS.net style?
thank you. Tag: Serialiazing a form Tag: 61689
What framework for MDI applications is recommended?
I came from a C++ MFC background to Windows Forms .NET
programming. Windows apps are best written on top of a
framework of some kind.
With Longhorn on its way, which framework for Windows
application programming is best as far as future Longhorn
compatibility?
Here is my contribution of a few ideas:
Microsoft Patterns and Practices Application Building
Blocks UI Process
Genghis: a GotDotNet workspace collaboration - MFC based.
A straight porting of MFC to .NET
However, I am not sure which is best and am looking for
ideas. Tag: Serialiazing a form Tag: 61680
Help Linking date to code
I have created a stored procedure which has a variable
called @date and I am trying to link this variable to the
date picker on my form but I need help. the code I have
done so far is below
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim sConnectionString As String = _
"server=localhost;uid=sa;pwd=sabril;dat
abase=optimussql"
Dim cnoptimus As New SqlConnection
(sConnectionString)
Dim cmdOrders As New SqlCommand("sales", cnoptimus)
cmdOrders.CommandType = CommandType.StoredProcedure
cmdOrders.Parameters.Add(New _
SqlParameter("@date", SqlDbType.VarChar, 11))
cmdOrders.Parameters("@date").Value = "MyDateValue"
Dim daGetOrders As New SqlDataAdapter(cmdOrders)
Dim dsOrders As New DataSet
daGetOrders.Fill(dsOrders, "st")
DataGrid1.DataSource = dsOrders.Tables("st")
End Sub
Private Sub DateTimePicker1_ValueChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
MyDateValue.ValueChanged
End Sub
End Class
Can anyone help me with the code or point me to some info
that will detail how to link a date picker to a stored
procedure proc
Regards
Newman Tag: Serialiazing a form Tag: 61676
Collection
Hi again
I've been trying to erase an element from a Collection,
but when I do this I get this exception
Object reference not set to an instance of an object.
This is my code
IEnumerator ie = Panel.Controls.GetEnumerator();
while(ie.MoveNext()) {
CheckBox chk = new CheckBox();
chk = (CheckBox)ie.Current;
if(chk.checked) {
Panel.Controls.Remove(chk);
}
}
And when I comment the condition, it removes only some
elements, for example, if the panel has 27 elements, it
removes 10 and it leaves 17.
What's wrong??
Regards Tag: Serialiazing a form Tag: 61675
Troubles with TreeViews
I am experiencing strange behavior from the Standard
Windows Forms TreeView control.
My application retrieves a dataset from a Web-Service. If
the download was sucessful, I call the Dataset.WriteXml()
method to persist the dataset to the local disk. The
next time the app runs, I check to see if the Xml file
exists, and if it does, I call ReadXml() instead of going
to the webservice. (The data doesn't change often).
From the dataset, I generate a six-level treeview.
Everything works fine the first time, until I choose to
refresh the dataset, and re-generate the treeview. The
tree goes blank, except for a single plus/minus image.
When I click on the 'node', it seems to expand, but no
data is being displayed.
I am doing the following when I refresh the data:
1. Clear the contents of the dataset
2. Retrieve the data again from the web-service
3. Remove all nodes from the tree-view
4. Re-build all nodes from the dataset
This process works great when I first run the program,
but when I try to refresh the dataset while it is
running, it gives me grief.
Anyone have any ideas? Sorry for the long winded
explanation. Any help would be appreciated.
........./mike Tag: Serialiazing a form Tag: 61674
ListView Paint
I got no answer before, so I'm reposting.
I have built a listview which I change the Size and View properties at run
time.
The imagelist associated to SmallList and LargeList properties is the same.
The problem is that it works great when View = LargeIcons, but it shows
blank/no icons at all when I set View to anything else. But, minimizing the
window OR sorting the listview solves the problem.
Seeing that I don't want to do any of these 2 things as a workaround, and
listview.Refresh() doesnt work at all, does anybody have any suggestion on
how to refresh the listview?
I have read something about Listview not invoking the Paint event.
Thanks! Tag: Serialiazing a form Tag: 61673
SQL server database
This is a multi-part message in MIME format.
------=_NextPart_000_000A_01C3B07E.0840D3E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
How can I create a SQL server database in my VB.NET program?
I've MSSQLServer installed and running.
If a database is created, where is it stored?
I used the following code, didn't get any errors, but cannot find a new =
file:
Dim con As SqlConnection =3D New =
SqlConnection("server=3D(local);Integrated =
Security=3DSSPI;database=3DSiteList")
Dim cmdLijst As SqlDataAdapter =3D New SqlDataAdapter("CREATE DATABASE =
", con)
'here some code to create the table?
'here some code to put the info from a dataset into the sql =
database?
con.close
Is with this code the database created?
thanks
Eric
------=_NextPart_000_000A_01C3B07E.0840D3E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>How can I create a SQL server database =
in my VB.NET=20
program?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I've MSSQLServer installed and=20
running.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>If a database is created, where is it=20
stored?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I used the following code, didn't get =
any errors,=20
but cannot find a new file:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Dim con As SqlConnection =3D New=20
SqlConnection("server=3D(local);Integrated=20
Security=3DSSPI;database=3DSiteList")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Dim cmdLijst As SqlDataAdapter =3D New=20
SqlDataAdapter("CREATE DATABASE ", con)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> 'here some code to =
create the=20
table?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> 'here some code to =
put the info=20
from a dataset into the sql database?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>con.close</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Is with this code the database=20
created?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Eric</FONT></DIV></BODY></HTML>
------=_NextPart_000_000A_01C3B07E.0840D3E0-- Tag: Serialiazing a form Tag: 61661
How does a MDIParent position its children
We are trying to control the cascading of mdi children as they open up. We
can do this with some success in the mdi child but it seems the parent
overrides what we do. What does a mdiparent do in regards to positioning
its child forms? Is there a way prior to or on the call to show to tell the
mdiparent where to position the child? Tag: Serialiazing a form Tag: 61655
converting a word doc into a pdf from a vb.net form
Hello everybody,
I have a treeview populated with folders and files shown on a WinForm. Some
files are word doc shown ..
I want to convert those doc into pdf and reload them ....and shown again on
the treeview..
can anybody help...
Appreciated
Thank u Tag: Serialiazing a form Tag: 61654
Stupid App.Config Question
I have a client app as one project and a data access class
library as another project. I have put app.config files
everywhere and named them everything. If I name it
MyApp.exe.config and put it in the client's bin directory,
the client can get to it but I can't make the data access
assembly access it.
Any Ideas?
Thanks Tag: Serialiazing a form Tag: 61653
Changes tracking
Hello,
Is there a mechanism allowing to know if the user has made a change in a
form containing many controls?
Thanks for help. Tag: Serialiazing a form Tag: 61652
Rename a folder maintaining its content from a VB.NET Form
Hello everybody,
Is it possible to rename a folder before showing it on a treeview on a
VB.NET form..The property .name is readonly..
can anybody help..
Thank u Tag: Serialiazing a form Tag: 61640
Make Container UserControl force controls to be added to a child container control
Hi,
I'm writing a container usercontrol. It consists of two panels. The first
panel is designed to act as a titlebar for the usercontrol. I want the
second panel to become the place where other controls are contained when
dropped on to it from a form designer (so they can never be positioned on
top of the title).
Is there any way of fooling the windows forms designer into adding contained
controls into the second panel, instead of the usercontrol itself?
I appreciate any help anyone can give me.
Thanks,
Trev. Tag: Serialiazing a form Tag: 61635
Question on MDI Forms Resizing and .Net Bug
When using an C# MDI Form, I have set the Child form's Minimize and Maximize
buttons to false, so they do not show up. But when I maximize the program
to fit a larger size window then what the default size is of the MDI Parent
is set to (programming this for a specific screen size), the Maximize and
Minimize buttons show up on the child form which can cause issues if someone
inadvertently uses them
I know this has been discussed before, and people have stated it is a bug in
.Net.
What I was wondering is if there are any examples of a code snippet that
finds the Size of the MDI Parent, then changes the size of the MDI Child
(similar to maximizing the Child form) so that the MDI Child will then be
"maximized" without initating that part of the .Net code. I was wondering
if by doing that throw separate code, the maximize and minimize buttons
would then not appear, and I could get around this problem.
Does anyone know of any examples, or something that could lead me down a
path to solving this?
Thanks,
T.Waldren Tag: Serialiazing a form Tag: 61632
Controls binded to datasource
This is a multi-part message in MIME format.
------=_NextPart_000_0008_01C3B04D.F9AEAAD0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello!
I have a panel in a form where to add controls, where the properties are =
loaded from a database, and the properties also are visible in a =
gridview (from developers express). The strange thing is that when I =
change the row in the gridview that object will be the visible one, and =
when checking (for each control...) the controls in the panel it's =
properties are equal to eachother, which they shouldn't (are not in the =
database). I think I've missed something with the binding, but I can't =
figure out what. Below you can see some of my code which loads the =
controls into the tab:
Regards Magnus
Private Sub LoadControlsTmp()
Dim st As String =3D "Prospects_Controls"
Dim cmd As New SqlClient.SqlCommand("select * from " & st & " where =
_TabID=3D" & cmbTabs.SelectedItem.IntID, cn)
da.SelectCommand =3D cmd
If ds.Tables.Count > 0 Then ds.Tables.Clear()
da.Fill(ds, st)
Panel3.Controls.Clear()
Dim dv As DataView =3D ds.Tables(st).DefaultView
GrdControl3.DataSource =3D dv
Dim drCTRL As DataRowView
For Each drCTRL In dv
Dim obj As New TextBox
obj.DataBindings.Add(New Binding("Text", dv, "CtrlText"))
obj.DataBindings.Add(New Binding("Name", dv, "CtrlName"))
Panel3.Controls.Add(obj)
Next
End Sub
------=_NextPart_000_0008_01C3B04D.F9AEAAD0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2713.1100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hello!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have a panel in a form where to add =
controls,=20
where the properties are loaded from a database, and the properties also =
are=20
visible in a gridview (from developers express). The strange thing is =
that when=20
I change the row in the gridview that object will be the visible one, =
and when=20
checking (for each control...) the controls in the panel it's =
properties=20
are equal to eachother, which they shouldn't (are not in the database). =
I think=20
I've missed something with the binding, but I can't figure out what. =
Below you=20
can see some of my code which loads the controls into the =
tab:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Regards Magnus</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT size=3D1><FONT face=3DArial><FONT =
color=3D#0000ff>Private</FONT> <FONT=20
color=3D#0000ff>Sub</FONT></FONT><FONT face=3DArial>=20
LoadControlsTmp()</FONT></FONT></DIV>
<DIV><FONT size=3D1><FONT face=3DArial><FONT =
color=3D#0000ff> =20
Dim</FONT> st <FONT color=3D#0000ff>As</FONT> <FONT=20
color=3D#0000ff>String</FONT></FONT><FONT face=3DArial> =3D=20
"Prospects_Controls"</FONT></FONT></DIV>
<DIV><FONT size=3D1><FONT face=3DArial><FONT =
color=3D#0000ff> =20
Dim</FONT> cmd <FONT color=3D#0000ff>As</FONT> <FONT=20
color=3D#0000ff>New</FONT></FONT><FONT face=3DArial> =
SqlClient.SqlCommand("select *=20
from " & st & " where _TabID=3D" & =
cmbTabs.SelectedItem.IntID,=20
cn)</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D1> da.SelectCommand =3D =
cmd</FONT></DIV>
<DIV><FONT size=3D1><FONT face=3DArial><FONT =
color=3D#0000ff> =20
If</FONT> ds.Tables.Count > 0 <FONT =
color=3D#0000ff>Then</FONT></FONT><FONT=20
face=3DArial> ds.Tables.Clear()</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D1> da.Fill(ds, =
st)</FONT></DIV>
<DIV><FONT face=3DArial size=3D1> =20
Panel3.Controls.Clear()</FONT></DIV>
<DIV><FONT size=3D1><FONT face=3DArial><FONT =
color=3D#0000ff> =20
Dim</FONT> dv <FONT color=3D#0000ff>As</FONT></FONT><FONT face=3DArial> =
DataView =3D=20
ds.Tables(st).DefaultView</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D1> =
GrdControl3.DataSource =3D=20
dv</FONT></DIV>
<DIV><FONT size=3D1><FONT face=3DArial><FONT =
color=3D#0000ff> =20
Dim</FONT> drCTRL <FONT color=3D#0000ff>As</FONT></FONT><FONT =
face=3DArial>=20
DataRowView</FONT></FONT></DIV>
<DIV><FONT size=3D1><FONT face=3DArial><FONT =
color=3D#0000ff> =20
For</FONT> <FONT color=3D#0000ff>Each</FONT> drCTRL <FONT=20
color=3D#0000ff>In</FONT></FONT><FONT face=3DArial> =
dv</FONT></FONT></DIV>
<DIV><FONT size=3D1><FONT face=3DArial><FONT =
color=3D#0000ff> =20
Dim</FONT> obj <FONT =
color=3D#0000ff>As</FONT></FONT><FONT=20
face=3DArial> <FONT color=3D#0000ff>New</FONT><FONT face=3DArial>=20
TextBox</FONT></FONT></FONT></DIV>
<DIV><FONT size=3D1><FONT =
face=3DArial> =20
obj.DataBindings.Add(</FONT><FONT face=3DArial =
color=3D#0000ff>New</FONT><FONT=20
face=3DArial> Binding("Text", dv, "CtrlText"))</FONT></FONT></DIV>
<DIV><FONT size=3D1><FONT face=3DArial> =
=20
obj.DataBindings.Add(</FONT><FONT face=3DArial =
color=3D#0000ff>New</FONT><FONT=20
face=3DArial> Binding("Name", dv, "CtrlName"))</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D1> =20
Panel3.Controls.Add(obj)</FONT></DIV>
<DIV><FONT color=3D#0000ff><FONT face=3DArial =
size=3D1> =20
Next</FONT></DIV></FONT>
<DIV><FONT face=3DArial><FONT size=3D1><FONT color=3D#0000ff>End</FONT> =
<FONT=20
color=3D#0000ff>Sub</DIV></FONT></FONT></FONT></BODY></HTML>
------=_NextPart_000_0008_01C3B04D.F9AEAAD0-- Tag: Serialiazing a form Tag: 61630
Howto Convert Icon to Image
Hello,
I have a very simple problem; maybe the answer is simple, too, but I did not
find one until now:
I have a System.Drawing.Icon object where I need a System.Drawing.Image
object.
How can I convert the Icon into an Image?
Dirk Ströker Tag: Serialiazing a form Tag: 61625
Menu Shortcuts X Windows Shortcuts
Hi
Lets say I have a text in a textbox control and I want to copy it.
Plus, I have a menuitem with a shortcut defined as Ctrl+C. Each menuitem
runs a script.
So I hit Ctrl + C in the textbox and BOOM, the menuitem executes first and
no text is copied.
I'm not sure of what I want, cause sometimes I will want the menu to "run",
and sometimes I need Windows to process the shorcut. It depends on what
control is foccused AND if the shorcut is handled by Windows (Ctrl + C, Ctrl
+ V)
I don't see how any key event can help me on this one.
Any ideas?
Thanks Tag: Serialiazing a form Tag: 61612
new to .net - is this easy?
Hi,
I've been doing a bit of work using a html control as the main interface on
my apps with JS code within the html to call into my application, defining a
COM object to handle this on the app side. Now a brand new project has come
up I was wondering whether the same process can be done easily on .net in
c++?
Basically the JS code within the html would call properties and methods on
the external object.
Can this be done, and if so how?
Cheers,
Phil. Tag: Serialiazing a form Tag: 61610
Sizing text to fit a rectangle
I have a status panel that is predefined size, but the string I display in
it can vary in size.
How do I check the physical length of my string against the width of the
status panel so I can modify my text to fit the panel
TIA
Tony Tag: Serialiazing a form Tag: 61605
ListView icons
What combination of proprties do you have to set in the
ListView to get a single state icon from an imagelist to
appear in an item? Tag: Serialiazing a form Tag: 61602
ScrollableControl
Does anyone know of a way to make a ScrollableControl update continuously as
the scrollbar is changed, instead of only when the scroll bar is released?
I want the extra speed from not having to repaint the whole window all the
time, but I can't find any way to make it behave like a "real" scrolling
control (tree, list, etc). Is this a built-in limitation, or is there some
property I'm missing?
Cheers,
Jason Dorie Tag: Serialiazing a form Tag: 61600
Win98 - VB.Net Installation
We had developed a solution in VB.Net and tried to install
it in Windows 98 OS.
As we open some forms the system stops responding. It has
to be rebooted.
We tried adding one form at a time to the project and check
if its due to any one particulr form. But unsuccessful.
If anyone has come accross with simillar problem.
Microsoft clearly says that .Net applications can be
deployed in Windows 98 OS.
Thankyou Tag: Serialiazing a form Tag: 61591
WebServices DataSet location
Subject: Windows distributed app
Data layer: SQL Server ( on separate machine )
Middle layer: WebServices on IIS ( on separate machine )
Question: Where DataSet is located - on WebServices
machine or on Client machine ... Or, how to make DateSet
to be located only on Client machine.
Thank you in advance
Gisa Tag: Serialiazing a form Tag: 61590
help with code
Can anyone help me with code to do the following
I have a stored procedure that requires a date. What I
want to do is to write an application that runs that
stored procedure and prompts the user for date/s to be
entered to run the stored procedure.
Can anyone help??
Regards
Newman Tag: Serialiazing a form Tag: 61589
Designing a Wizard
I am creating a setup/installation wizard using C# and Windows.Forms. The
application consists of a single form which displays multiple wizard
"pages". The pages are displayed one at a time when the user clicks on the
Back and Next buttons. Only one page is visible at any one time. How
should I design this application with the Visual Studio .NET designer?
My first idea was to create a multiple classes that derive from Panel, one
for each different wizard page and one for the 3 buttons that appear on
every wizard page. However, I cannot design a panel in the Visual Studio
.NET designer. I can only design a Form, Control, or UserControl.
My second idea was to create multiple classes that derive from UserControl,
one for each different wizard page and one for the 3 buttons that appear on
every wizard page. However, I don't understand how to drag and drop my
custom user controls onto my other GUI objects. It appears I have to put my
controls in a separate library project and then reference the resulting
assembly. Having two projects instead of one seems overly complex.
Is there a better solution?
Mike Bresnahan Tag: Serialiazing a form Tag: 61588
Sorting CheckBoxes
Hi,
I have a panel under which i have lot of checkboxes added during
runtime...which can have three values for priority(low,high,medium) i have
set docking = top ; now my problem is i have to sort these checkboxes
according to their priority ... any optimal way to do it...
Regards,
... Tag: Serialiazing a form Tag: 61586
Hi,
i want to persist a few properties of a form ...how do i do it ? any
leads is greatly appriciated
Ken
----------------------------
"NotYetaNurd" <NotYetaNurd@Matrix.com> wrote in message
news:OtNvdunsDHA.4088@TK2MSFTNGP11.phx.gbl...
> Hi,
> i want to persist a few properties of a form ...how do i do it ? any
> leads is greatly appriciated
>
> regards,
> ...
>
>
"NotYetaNurd" <NotYetaNurd@Matrix.com> wrote in message
news:OtNvdunsDHA.4088@TK2MSFTNGP11.phx.gbl...
> Hi,
> i want to persist a few properties of a form ...how do i do it ? any
> leads is greatly appriciated
>
> regards,
> ...
>
>