私は、ユーザーがクライアント情報を入力する必要があるアプリケーションを作成しています。この情報は次のページに送られ、テーブル形式で表示されます。値を挿入することはできますが、テーブル形式で再検索することはできません。助けてください。Xamarin IOS SQLite
private string pathtoDatabase;
public RoofExisting(IntPtr handle) : base(handle)
{
var documentFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
pathtoDatabase = Path.Combine(documentFolder, "ClientInfo_db.db");
using (var connection = new SQLiteConnection(pathtoDatabase))
{
var con = connection.Table<ClientInfo>();
foreach (var item in con)
{
ClientInfo Info = new ClientInfo(item.projectno, item.ClientName, item.CCompany, item.Caddress, item.CPostal, item.CPhonen, item.CEmail);
//Adding in the table view
CNinfo.Source = new TableSource(Info, this);
}
}
}
class TableSource:UITableViewSource
{
protected string[] tableItems;
protected String cellidentifier = "TableCell";
ViewController owner;
private ClientInfo info;
private RoofExisting roofExisting;
public TableSource(String[] items, ViewController owner)
{
tableItems = items;
this.owner = owner;
}
public TableSource(ClientInfo info, RoofExisting roofExisting)
{
this.info = info;
this.roofExisting = roofExisting;
}
public override nint RowsInSection(UITableView tableview, nint section)
{
return tableItems.Length;
}
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
UIAlertController alertcontroller = UIAlertController.Create("Row Selected", tableItems[indexPath.Row], UIAlertControllerStyle.Alert);
alertcontroller.AddAction(UIAlertAction.Create("ok",UIAlertActionStyle.Default,null));
owner.PresentViewController(alertcontroller,true,null);
tableView.DeselectRow(indexPath,true);
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell(cellidentifier);
if (cell == null)
cell = new UITableViewCell(UITableViewCellStyle.Default, cellidentifier);
cell.TextLabel.Text = tableItems[indexPath.Row];
return cell;
}
}