|
Hi Dave,
Of course I'll have to loop over the cells and to loose information when displaying the smaller picture. The question is how am I displaying the picture ?. I can define a Bitmap object (smaller than the array) but how can I display the bitmap without saving it on H.D. ?
Thanks
|
|
|
|
|
Create a custom control, its the easiest.
override OnPaint(PainteventArgs pea)
{
Bitmap b = new Bitmap(10000,10000);
pea.Graphics.Transform = new Matrix(Width/10000f,0,0,Height/10000f,0,0);
pea.Graphics.DrawImage(b);
b.Dispose();
}
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
Hi,
can anyone suggest some source code to read XML files.
Any help would be much appreciated...
Cheers
|
|
|
|
|
Search MSDN msdn.microsoft.com[^] for XmlTextReader . Or search web for "reading XML in C#" or something like that. It usualy saves out time and leads to your answer When you run into problem come back.. you are welcomed.
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
hi can anyone help me to append this code, to have autocomplete combobox in datagrid ?
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using System.Diagnostics;
namespace Stock
{
// Derive class from DataGridTextBoxColumn
public class DataGridComboBoxColumnNAME : DataGridTextBoxColumn
{
// Hosted ComboBox control
// private AutoCompleteComboBoxNAME comboBox;
private ComboBox comboBox;
private CurrencyManager cm;
private int iCurrentRow;
// Constructor - create combobox, register selection change event handler,
// register lose focus event handler
public DataGridComboBoxColumnNAME()
{
this.cm = null;
// Create ComboBox and force DropDownList style
this.comboBox = new ComboBox();
this.comboBox.DropDownStyle = ComboBoxStyle.DropDown;
this.comboBox.Sorted = true;
// 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();
//this.comboBox.SelectedIndex = 0;
}
}
// 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)
{
try
{
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();
//MessageBox.Show(s);
this.DataGridTableStyle.DataGrid.Scroll -= new EventHandler(DataGrid_Scroll);
}
catch
{
}
}
}
}
|
|
|
|
|
i can not programmaticly set dateee.Checked = false; once it was set true.
Where is the trick?
|
|
|
|
|
If the .ShowCheckBox property set to true ?
DateTimePicker.Checked Property[^] docs on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
ShowCheckBox is set true ...and its checked in my datepicker box.
now i wana set it to unchecket state again (while program running) with Checked = false but nothing happen. the datepicker checkbox stays checked.
|
|
|
|
|
That's indeed a bug. When you set its Checked property to false , it actually becomes false , but the control still is painted as if it were true .
I remember reading about it, and what I recall to have worked is to set the Checked property to true and then immediately to false .
Try that and tell us if it works.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
thats exactly how i solve it. if i want to set checkbox in unchecked state, i have to set it first true and then immediately to false. i also noticed...
if you programmaticly set value to same date that already is (checkbox is unchecked), checkbox dont get automaticly checked. i think that checkbox should get checked=true(automaticly) every time you set a value, if we look that checked is set to false by default.i see checkbox as an confirmation that value was really set.
|
|
|
|
|
I have used the checkbox in the DateTimePicker control to register the date when a vaccine was applied to a child. If the the checkbox is checked, then the vaccine has been applied and the date specifies when. If the checkbox is unchecked, the vaccine hasn't been applied, and the date doesn't matter (it's grayed out.)
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I need to create 2 dimensional arrays. How can I store them? I don`t know how many of them, so the collection must be done dynamicaly.
The second qestion is, how can I display all of that arrays in one ie List box, data grid?
thx
|
|
|
|
|
Just create an Arraylist of arrays. Like
public class Foo
{
ArrayList list = new ArrayList();
public void Add(int []x)
{
list.Add(x);
}
public void ListAll()
{
foreach(int [] arr in list)
{
for(int i = 0; i<arr.Length; ++i)
Console.WriteLine(arr[i]);
}
}
}
Each element in list can be an array of any size and there can be as many elements in the list as you want.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks,
but how can I display every element of this list at once (containing 2 dimensional array objects) in windows forms ?
Maybe use data grid, but have no idea how to.
|
|
|
|
|
I'm trying to open a local file in the WebBrowser control but I cannot figure out, how to do it.
How do I do that?
|
|
|
|
|
How to view AutoCad file in C# like zoom in, view, zoom out. Please tell me. Thank.
|
|
|
|
|
You're going to need a component that can read and understand the file format and render it properly. I don't know of any. You might want to check with AutoDesk to see if they have something that might work.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am running the following code. It executes when the value of variable i is 1 and when the loop continues and value of i becomes 2 i am getting error "Object reference not set to an instance of an object" in the cmdSearch.CommandText line in the code. . There is no problem with connection string. It successfully retrieves when i = 1. Can anybody help me out what is the problem. Please post with corrected code if anybody can help.
===========================================
for (int i=1; i <= objFolder.Items.Count; i++)
{
System.Data.OleDb.OleDbConnection odbSearch = new System.Data.OleDb.OleDbConnection();
System.Data.OleDb.OleDbCommand cmdSearch = new System.Data.OleDb.OleDbCommand();
odbSearch.ConnectionString = strConn;
cmdSearch.Connection = odbSearch;
item = (Outlook.ContactItem) objFolder.Items.Item(i);
string em = item.Email1Address;
cmdSearch.CommandText = "select * from Outlook_Contacts where FirstName='"+fn.ToString().Trim()+"' and LastName='"+ln.ToString().Trim()+"'";
odbSearch.Open();
OleDbDataReader rdrSearch = cmdSearch.ExecuteReader();
while( rdrSearch.Read())
{
RecordFlag = true;
}
odbSearch.Close();
}
===========================================
|
|
|
|
|
What are fn and ln? Where are they defined?
|
|
|
|
|
fn and ln are declared outside and the values are properly getting passed to those variables. The code executes when i=1 and when the value of i becomes 2 the error occurs. There is no problem with connection string also. only when the code executes to the commandtext line it shows the error. that too i am getting one record successfully(when i = 1). hope this helps
|
|
|
|
|
well, some thing is null. It is either item, cmdSearch, fn or ln.
can you step through it in VS and check?
|
|
|
|
|
I have done that. I am getting one record ie. when the value of i = 1. When the value of i increases to 2 then in the commandtext line this error occurs. And also fn and ln are fine. Can you please tell me how to solve it?
|
|
|
|
|
Like bigtrev said, just step through and check fn and ln .
Or perhaps you got the line number wrong and item is null.
Anyway, just step through and check.
Btw. you know that building SQL commands the way you do is highly vulnerable to SQL injection?
You should use parameterized queries instead.
Regards,
mav
|
|
|
|
|
hi,
when enabling visual style in an application ,tool bar button disappear , how to cater it so that visual style and tool bar button can be enable at the same time.
|
|
|
|
|
Don't forget the call to Application.DoEvents();
Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new AgilePlannerMainForm());
Maybe that solves your problem.
Claudio
Claudio's Website
|
|
|
|