|
See this[^] article.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thank you for this. I just happened to be in the right place at the right time lol
Regards,
Jason Pezzimenti.
|
|
|
|
|
If a text file is opened and given to print for a printer installed on the PC, how to catch the data that is going to printer before it gets printed.
|
|
|
|
|
hi evry1!
i needed to create a form in which i hav to browse and open mdb files ---> i did this part usin oprnfile dialogue!
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog oDlg = new OpenFileDialog();
oDlg.Title = "Select MDB";
oDlg.Filter = "MDB (*.Mdb)|*.mdb";
oDlg.RestoreDirectory = true;
string dir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
oDlg.InitialDirectory = dir;
DialogResult result = oDlg.ShowDialog();
if (result == DialogResult.OK)
{
textBox1.Text = oDlg.FileName.ToString();
}
}
this is my code so far!!!
now i need to make 3 list boxes!!
1st one to display the table names of the db!
2nd to to display field names when clicked on table name!!!
3rd to display attributes on fiels on clickin on it!
v can edit the attribute values and on clickin of save button it should update the database!!!
pls help
|
|
|
|
|
|
if u could b specific it wud b gr8
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog oDlg = new OpenFileDialog();
oDlg.Title =
"Select MDB";
oDlg.Filter =
"MDB (*.Mdb)|*.mdb";
oDlg.RestoreDirectory =
true;
string dir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
oDlg.InitialDirectory = dir;
DialogResult result = oDlg.ShowDialog();
if (result == DialogResult.OK)
{
textBox1.Text = oDlg.FileName.ToString();
}
string strFileName = oDlg.FileName.ToString();
OleDbConnection cn = new OleDbConnection();
DataTable schemaTable;
cn.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Mode=Share Deny None;Data Source="+strFileName;
cn.Open();
schemaTable = cn.GetOleDbSchemaTable(
OleDbSchemaGuid.Tables,
new Object[] { null, null, null, "TABLE" });
//List the table name from each row in the schema table.
for (int i = 0; i < schemaTable.Rows.Count; i++)
{
strTableName = schemaTable.Rows[i].ItemArray[2].ToString();
listBox1.Items.Add(strTableName);
}
//Explicitly close - don't wait on garbage collection.
cn.Close();
}
this is my code so far!!!
now i need to make 3 list boxes!!
1st one to display the table names of the db<-----done till here!!!!
2nd to to display field names when clicked on table name!!!---> to b done!
3rd to display attributes on fiels on clickin on it!!!---> to b done!v can edit the attribute values and on clickin of save button it should update the database!!!
|
|
|
|
|
i need to make 3 list boxes!!
1st one to display the table names of the db<-----done till here!!!!
2nd to display field names when clicked on table name!!!<-----done till here!!!!
3rd to display attributes of the fields on clickin on it!!!---> to b done!
4.v shud b able to edit the attribute values and on clickin of save button it should update the database!!! ---> to b done!
this is my code so far!!!
.
.
public partial class Form1 : Form
{
private OleDbConnection cn = new OleDbConnection();
private DataTable schemaTable;
public Form1()
{
InitializeComponent();
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Mode=Share Deny None;Data Source=";
}
private void button1_Click(object sender, EventArgs e)
{
cn.Close();
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Mode=Share Deny None;Data Source=";
listBox1.Items.Clear();
listBox2.Items.Clear();
OpenFileDialog oDlg = new OpenFileDialog();
string strFileName = "";
oDlg.Title = "Select MDB";
oDlg.Filter = "MDB (*.Mdb)|*.mdb";
oDlg.RestoreDirectory = true;
string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
oDlg.InitialDirectory = dir;
DialogResult result = oDlg.ShowDialog();
if (result == DialogResult.OK)
{
strFileName = oDlg.FileName.ToString();
textBox1.Text = strFileName;
}
cn.ConnectionString += strFileName;
cn.Open();
schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new Object[] { null, null, null, "TABLE" });
//List the table name from each row in the schema table.
for (int i = 0; i < schemaTable.Rows.Count; i++)
{
string strTableName = schemaTable.Rows[i].ItemArray[2].ToString();
listBox1.Items.Add(strTableName);
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
listBox2.Items.Clear();
string strTableName = listBox1.SelectedItem.ToString();
schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
new Object[] { null, null, strTableName, null });
//List the column name from each row in the schema table.
for (int i = 0; i < schemaTable.Rows.Count; i++)
{
string strColName = schemaTable.Rows[i].ItemArray[3].ToString();
listBox2.Items.Add(strColName);
}
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
listBox3.Items.Clear();
string strTableName = listBox1.SelectedItem.ToString();
schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
new Object[] { null, null, strTableName, null });
//List the column name from each row in the schema table.
for (int i = 0; i < schemaTable.Rows.Count; i++)
{
string strColItm = schemaTable.Rows[i].ItemArray[4].ToString();
listBox2.Items.Add(strColItm);
}
}
}
|
|
|
|
|
Hi everyone,
1- How can we rename Column Header Text in DataGridView? Is that possible to make the header editable?
2- Can we show or hide Columns in DataGridView?
3- How can we swap column positions if column are in numbers and we have to horizontally scroll to access different columns?
Thanks.
Good Day.
|
|
|
|
|
1 column[1].caption = "this col"
1a I am pretty sure a header can not be made editable, that would make it like any other row. You could work around this with a dummy row
2 column[1].visible = false
3 set the ordinal position of the column (I have never done this so I am not sure)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hello
i made one login form after username and password type
when login button enter i need to fire login button event
i used the acceptbutton property in form but in this property i need to enter two times but here i need one enter button press to go fire
please give me the solution
|
|
|
|
|
Hi, nobody is going to just give you the solution. Can you post the code for the login button that you have?
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Set AcceptButton Property of form to the login button
Reg
Deep
Happy Coding
|
|
|
|
|
i set the acceptbutton property the login button
but i need two times enter to go
|
|
|
|
|
In that case, something in your code or another control is consuming the first Enter, as it should just work with one press. Without seeing the code it's impossible to diagnose what's causing the problem.
This works for me.
using System;
using System.Drawing;
using System.Windows.Forms;
public partial class FormLogIn : Form
{
TextBox textBoxUserName;
TextBox textBoxPassword;
Button buttonLogIn;
public FormLogIn()
{
InitializeComponent();
SuspendLayout();
textBoxUserName = new TextBox();
textBoxUserName.Location = new Point(12, 12);
textBoxPassword = new TextBox();
textBoxPassword.Location = new Point(12, 38);
textBoxPassword.UseSystemPasswordChar = true;
buttonLogIn = new Button();
buttonLogIn.Text = "Log In";
buttonLogIn.Location = new Point(12, 64);
buttonLogIn.Click += buttonLogIn_Click;
MinimizeBox = false;
MaximizeBox = false;
FormBorderStyle = FormBorderStyle.FixedSingle;
StartPosition = FormStartPosition.CenterScreen;
Size = new Size(132, 132);
Text = "Log In";
AcceptButton = buttonLogIn;
Controls.AddRange(new Control[] { textBoxUserName, textBoxPassword, buttonLogIn });
ResumeLayout(false);
}
void buttonLogIn_Click(object sender, EventArgs e)
{
Close();
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
public class TXDataGridViewNumericColumn : DataGridViewColumn
{
public TXDataGridViewNumericColumn() : base(new TXNumericCell())
{
this.InputType = NumericType.Integer;
}
public override DataGridViewCell CellTemplate
{
get
{
return base.CellTemplate;
}
set
{
if (value != null &&
!value.GetType().IsAssignableFrom(typeof(TXNumericCell)))
{
throw new InvalidCastException("Must be a CalendarCell");
}
base.CellTemplate = value;
}
}
private NumericType m_NumericType;
public enum NumericType
{
Decimal,
Integer,
PositiveDecimal,
NegativeDecimal,
PositiveInteger,
NegativeInteger
}
public NumericType InputType
{
get { return m_NumericType; }
set { m_NumericType = value; }
}
public ICollection testCollection
{
get
{
return Icollection;
}
set
{
Icollection = value;
}
}
private ICollection Icollection;
public override object Clone()
{
DataGridViewColumn col = (DataGridViewColumn)base.Clone();
col.CellTemplate = new TXNumericCell();
return col;
}
}
public class TXNumericCell : DataGridViewTextBoxCell
{
public TXNumericCell() : base()
{
}
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
{
base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
TXNumericEditControl ctl = DataGridView.EditingControl as TXNumericEditControl ;
ctl.Text = (string )this.Value;
}
public override Type EditType
{
get
{
return typeof(TXNumericEditControl);
}
}
public override Type ValueType
{
get
{
return typeof(string);
}
}
public override object DefaultNewRowValue
{
get
{
return string.Empty;
}
}
}
class TXNumericEditControl :TXNumeric , IDataGridViewEditingControl
{
DataGridView dataGridView;
private bool valueChanged = false;
int rowIndex;
public TXNumericEditControl()
{
TXDataGridViewNumericColumn current = new TXDataGridViewNumericColumn();
this.InputType =(NumericType)current.InputType;
}
public object EditingControlFormattedValue
{
get
{
return this.Text ;
}
set
{
String newValue = value as String;
if (newValue != null)
{
this.Text = newValue;
}
}
}
public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
{
return EditingControlFormattedValue;
}
public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
{
this.Font = dataGridViewCellStyle.Font;
this.ForeColor = dataGridViewCellStyle.ForeColor;
this.BackColor = dataGridViewCellStyle.BackColor;
}
public int EditingControlRowIndex
{
get
{
return rowIndex;
}
set
{
rowIndex = value;
}
}
public bool EditingControlWantsInputKey( Keys key, bool dataGridViewWantsInputKey)
{
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Up:
case Keys.Down:
case Keys.Right:
case Keys.Home:
case Keys.End:
case Keys.PageDown:
case Keys.PageUp:
return true;
default:
return false;
}
}
public void PrepareEditingControlForEdit(bool selectAll)
{
// No preparation needs to be done.
}
public bool RepositionEditingControlOnValueChange
{
get
{
return false;
}
}
public DataGridView EditingControlDataGridView
{
get
{
return dataGridView;
}
set
{
dataGridView = value;
}
}
public bool EditingControlValueChanged
{
get
{
return valueChanged;
}
set
{
valueChanged = value;
}
}
public Cursor EditingPanelCursor
{
get
{
return base.Cursor;
}
}
protected override void OnTextChanged(EventArgs e)
{
valueChanged = true;
this.EditingControlDataGridView.NotifyCurrentCellDirty(true);
base.OnTextChanged(e);
}
}
public partial class TXNumeric : TextBox
{
private NumericType m_NumericType;
public enum NumericType
{
Decimal,
Integer,
PositiveDecimal,
NegativeDecimal,
PositiveInteger,
NegativeInteger
}
public TXNumeric()
{
this.InputType = NumericType.Integer;
this.ContextMenu = new ContextMenu();//屏蔽系统的菜单
}
public NumericType InputType
{
get { return m_NumericType; }
set { m_NumericType = value; }
}
#region user-defined method
private bool IsValid(string val, bool user)
{
bool ret = true;
if (val.Equals("") || val.Equals(String.Empty))
return ret;
if (user)
{
if (val.Equals("-"))
return ret;
}
try
{
switch (m_NumericType)
{
case NumericType.Decimal:
ret=this.IsValidNumeric(val);
break;
case NumericType.PositiveDecimal:
ret=this.IsValidPositiveNum(val);
break;
case NumericType.NegativeDecimal:
ret = this.IsValidNegativeNum(val);
break;
case NumericType.Integer:
ret = this.IsValidInt(val);
break;
case NumericType.PositiveInteger:
ret = this.IsValidPositiveInt(val);
break;
case NumericType.NegativeInteger:
ret = this.IsValidNegativeInt(val);
break;
//default:
// throw new ApplicationException();
}
}
catch
{
ret = false;
}
return ret;
}
/// <summary>
/// judge data if it is numeric type
/// </summary>
/// <param name="strData"></param>
/// <returns>bool</returns>
private bool IsValidInt(string strData)
{
int intData;
try
{
intData = Convert.ToInt32(strData);
return true;
}
catch
{
return false;
}
}
private bool IsValidPositiveInt(string strData)
{
int intData;
try
{
intData = Convert.ToInt32(strData);
if (intData > 0)
{ return true; }
else
{ return false; }
}
catch
{
return false;
}
}
private bool IsValidNegativeInt(string strData)
{
int intData;
try
{
intData = Convert.ToInt32(strData);
if (intData < 0)
{ return true; }
else
{ return false; }
}
catch
{
return false;
}
}
private bool IsValidNumeric(string strData)
{
double dblData;
try
{
dblData = Convert.ToDouble(strData);
return true;
}
catch
{
return false;
}
}
private bool IsValidPositiveNum(string strData)
{
double dblData;
try
{
dblData = Convert.ToDouble(strData);
if (dblData > 0)
{ return true; }
else
{ return false; }
}
catch
{
return false;
}
}
private bool IsValidNegativeNum(string strData)
{
double dblData;
try
{
dblData = Convert.ToDouble(strData);
if (dblData < 0)
{ return true; }
else
{ return false; }
}
catch
{
return false;
}
}
#endregion
#region override system method
public override string Text
{
get { return base.Text; }
set
{
if (IsValid(value, true))
base.Text = value;
}
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
// trap Ctrl-V paste and prevent invalid values
// return false to allow further processing
if (keyData == (Keys)Shortcut.CtrlV || keyData == (Keys)Shortcut.ShiftIns)
{
IDataObject iData = Clipboard.GetDataObject();
// assemble new string and check IsValid
string newText;
newText = base.Text.Substring(0, base.SelectionStart)
+ (string)iData.GetData(DataFormats.Text)
+ base.Text.Substring(base.SelectionStart + base.SelectionLength);
// check if data to be pasted is convertable to inputType
if (!IsValid(newText, true))
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
protected override void OnLeave(EventArgs e)
{
// handle - and leading zeros input since KeyPress handler must allow this
if (base.Text != "")
{
if (!IsValid(base.Text, false))
base.Text = "";
else if (Double.Parse(base.Text) == 0) // this used for -0, 000 and other strings
base.Text = "0";
}
base.OnLeave(e);
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
char c = e.KeyChar;
if (!Char.IsControl(c)) // not sure about this?? nothing in docs about what is Control char??
{
// prevent spaces
if (c.ToString() == " ")
{
e.Handled = true;
return;
}
string newText = base.Text.Substring(0, base.SelectionStart)
+ c.ToString() + base.Text.Substring(base.SelectionStart + base.SelectionLength);
if (!IsValid(newText, true))
e.Handled = true;
}
base.OnKeyPress(e);
}
#endregion
}
I define a column by inheritting the DataGridViewColumn, and add a property for this column, but in the design-mode
when I change the value of this property , the value can not be saved, ALl the codes as above.
thanks
|
|
|
|
|
No one will read such a long post. Don't dump all your code. Please modify your post and put only the code that is relevant and wrap it inside <pre></pre> tags so that CP will format it.
|
|
|
|
|
in a webservice i'm using xsd generated class(person) object to fill data and return a person type object to the caller. in the caller side also i create an object of person class generated by same xsd.
in java client the returned object can be directly assigned to the local person type object.
but in .net it says "cannot convert localhost.person to person".my webrefernce is localhost.
|
|
|
|
|
prasadbuddhika wrote: but in .net it says "cannot convert localhost.person to person".my webrefernce is localhost.
Both are different types under different name space. You can't assign even if it looks similar. Why don't you use it like,
localhost.person p = /* .. */
VS might have generated a person class automatically. All you need is to reuse it.
prasadbuddhika wrote: in java client the returned object can be directly assigned to the local person type object.
Not sure how this is happening. AFAIK, Java doesn't allow Duck Typing[^] (this kind of behavior is known as duck typing, right?).
|
|
|
|
|
thanks , but navaneeth webservices are intended to work platform independently , and xsd format is used to create a common complex type for both server and client, isn't it ?
here the problem is when the namespace.object is created the values should be assigned to another object individually.
the other thing is in the C# client side also i have created an object from xsd generated class.what i want is directly assign the return object to the local object .
any suggestions
|
|
|
|
|
prasadbuddhika wrote: webservices are intended to work platform independently , and xsd format is used to create a common complex type for both server and client, isn't it ?
Yes. When a web service is referenced using VS, Visual studio reads the XSD and creates proxy classes for you. This helps you not to write your own classes.
If you need your own class, then you need to parse the SOAP message and assign values to the fields manually.
|
|
|
|
|
I doing a project to send sms or mms to mobile phone from server using C Sharp. Can anyone help me with it. Thanks
Send the source code to xiaoice_88@hotmail.com
|
|
|
|
|
Most carriers allow email to SMS with the phone number.
some examples I know off handcompany name | email |
---|
T-Mobile: | phonenumber@tmomail.net | Sprint: | phonenumber@messaging.sprintpcs.com | Verizon: | phonenumber@vtext.com |
|
|
|
|
|
pearllyn wrote: Send the source code to xiaoice_88@hotmail.com
Reply to me too LOL
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
I am trying to create an application in C# which will extract and save RSS feeds onto the D drive. I am using the following C# code to save the file on the disk
rssReader = new XmlTextReader(FeedAddress.Text);
rssDoc = new XmlDocument();
//Load the XML contents into a XMLDocument
rssDoc.Load(rssReader);
rssDoc.Save("D://text.xml");
Everything works wells and the file is saved in the "utf-8" format if the extension of the link is XML (e.g http://msdn.microsoft.com/rss.xml). The problem comes when I try to save a feed with .rss extension (e.g http://orangecounty.craigslist.org/apa/index.rss), instead of saving the feed in "utf-8" format it saves the feed in "ISO-8859-1" format.
Moreover, when I try to save the feed with .rss extension using the Save As option of the Internet Explorer it saves the feed in "utf-8" format but when I use the C# code to save the same feed it saves it in the "ISO-8859-1" format.
Is there any way to save the feed with .rss extension in "utf-8" format instead of "ISO-8859-1" format?
Thanks
|
|
|
|